Wednesday, November 23, 2016

PowerShell v2 IIS 7 5 Accessing MACHINE WEBROOT

,
I was trying to check some settings on a machine level .config file. I stumbled across a reference in my favorite IIS-PowerShell link of all time:
IIS Powershell User guide - Comparing representative IIS UI tasks
Under 30. [Management] Configure Feature Delegation related settings I found this example:
clear-webconfiguration /system.webServer/asp -pspath MACHINE/WEBROOT/APPHOST
Though this isnt what I wanted to do it does highlight that the machine/webroot I want to update can be referenced via the -PSPath parameter. This can be verified by tweaking a random property in the webroot (i.e., server level) of an IIS server using Configuration Manager and clicking the Generate Script link button. Within the script you can see the path matches what is shown above.

So, if you are looking for ways to manipulate the base configuration data outside of the Sites provider path (IIS:Sites), you can reverse the location with IIS 7.5 Manager. Once you have your path, simply plug it into the Cmdlets -PSPath and run with it. Here is a sample:
Get-WebConfiguration -PSPath machine/webroot -filter *
This simply returns the sections under the machine/webroot file:
SectionPath PSPath Location
----------- ------ --------
/appSettings MACHINE/WEBROOT
/connectionStrings MACHINE/WEBROOT
/system.windows.forms MACHINE/WEBROOT
/configProtectedData MACHINE/WEBROOT
/system.codedom MACHINE/WEBROOT
/system.data MACHINE/WEBROOT
/system.diagnostics MACHINE/WEBROOT
As you explore you can get more explict to see what exists under a give node (remember it is IIS and XML under the hood now):
Get-WebConfiguration -PSPath machine/webroot -filter appSettings -Recurse | select *
Without some background in IIS it is hard to know what to make of this, but, the basic breakdown of the .config files and how they overlap reveals a great deal about the -PSPath parameter when using something other than the standard IIS: provider.

0 comments to “PowerShell v2 IIS 7 5 Accessing MACHINE WEBROOT”

Post a Comment

 

Computer Info Copyright © 2016 -- Powered by Blogger