windows - Cannot load IIS config powershell -


i have windows server 2016

this code works in powershell ise:

ps c:\users\iadmin>[system.reflection.assembly]::loadwithpartialname("microsoft.web.administration")| out-null;  ps c:\users\iadmin> $servermanager = (new-object microsoft.web.administration.servermanager);  ps c:\users\iadmin> $servermanager.getadministrationconfiguration().getsection("system.webserver/management/delegation"); 

but in plain powershell cmdline not:

ps c:\users\iadmin>[system.reflection.assembly]::loadwithpartialname("microsoft.web.administration")| out-null;  ps c:\users\iadmin> $servermanager = (new-object microsoft.web.administration.servermanager);  ps c:\users\iadmin> $servermanager.getadministrationconfiguration().getsection("system.webserver/management/delegation") exception calling "getsection" "1" argument(s): "filename: \\?\c:\windows\system32\windowspowershell\v1.0\config\administration.config error: configuration section 'system.webserver/management/delegation' cannot read because missing section declaration " @ line:1 char:1 + $servermanager.getadministrationconfiguration().getsection("system.we ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     + categoryinfo          : notspecified: (:) [], methodinvocationexception     + fullyqualifiederrorid : comexception   ps c:\users\iadmin>  

when there exception:

exception calling "getsection" "1" argument(s): "filename: \\?\c:\windows\system32\windowspowershell\v1.0\config\administration.config 

so looks cannot find proper path iis config, when specify in powershell direct path ise applicationhost.config, loads it, when trying section, throws cannot find schema, despite schema there:

ps c:\users\iadmin> [system.reflection.assembly]::loadwithpartialname("microsoft.web.administration")| out-null;  ps c:\users\iadmin> $servermanager = (new-object microsoft.web.administration.servermanager 'c:\windows\system32\inetsrv\config\applicationhost.config');  ps c:\users\iadmin> $servermanager.getadministrationconfiguration().getsection("system.webserver/management/delegation") exception calling "getsection" "1" argument(s): "filename:  error: configuration section 'system.webserver/management/delegation' cannot read because missing schema " @ line:1 char:1 + $servermanager.getadministrationconfiguration().getsection("system.we ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     + categoryinfo          : notspecified: (:) [], methodinvocationexception     + fullyqualifiederrorid : filenotfoundexception   ps c:\users\iadmin> 

also note section system.webserver/management/delegation added webdeploy , schema there

getting standard iis section works without problem:

ps c:\users\iadmin> $servermanager.getadministrationconfiguration().getsection("system.webserver/management/authentication").getcollection(); 

i tried check environment variables, load same assemblies in ise in plain powershell, load same modules, without success


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -