Question

I found the code that I think that i need to use, but the thing is that it is not working.

Import-Module WebAdministration
$appPools = Get-childItem 'IIS:\AppPools\App Pool'
Set-ItemProperty -Path $appPools -Name recycling.periodicRestart.time -Value 1.00:00:00

But I am getting this error

Set-ItemProperty : Cannot find path 'C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Modules\WebAdministration\Microsoft.IIs.PowerShell.Framework.NodeCollection' because it does not exist.
At line:3 char:1
+ Set-ItemProperty -Path $appPools -Name recycling.periodicRestart.time -Value 1.0 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (C:\Windows\SysW....NodeCollection:String) [Set-ItemProperty], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetItemPropertyCommand

I know it isn't a path issue. This does work.

set-itemproperty -path 'D:\test\TestPS\New Text.txt' -name IsReadOnly -value $true

Any help would be great...

Was it helpful?

Solution

It is a path issue.

The object returned from Get-ChildItem 'IIS:\AppPools\App Pool' is a NodeCollection object, and when you run Set-ItemProperty -Path $appPools, $appPools is expanded to "Microsoft.IIs.PowerShell.Framework.NodeCollection" (which is not a valid path)

To change the properties of the app pool:

Set-ItemProperty -Path 'IIS:\AppPools\App Pool' -Name recycling.periodicRestart.time -Value 1.00:00:00
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top