Frage

Ich habe den Code gefunden, den ich meiner Meinung nach verwenden muss, aber die Sache ist, dass er nicht funktioniert.

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

Aber ich erhalte diesen Fehler

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

Ich weiß, dass es kein Pfadproblem ist.Das funktioniert.

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

Jede Hilfe wäre großartig...

War es hilfreich?

Lösung

Es Ist ein Pfadproblem.

Das von zurückgegebene Objekt Get-ChildItem 'IIS:\AppPools\App Pool' ist ein NodeCollection Objekt, und wenn Sie laufen Set-ItemProperty -Path $appPools, $appPools wird zu „Microsoft.IIs.PowerShell.Framework.NodeCollection“ erweitert (was kein gültiger Pfad ist)

So ändern Sie die Eigenschaften des App-Pools:

Set-ItemProperty -Path 'IIS:\AppPools\App Pool' -Name recycling.periodicRestart.time -Value 1.00:00:00
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top