Script Powershell pour modifier le temps de recyclage sur le pool d'applications
-
26-12-2019 - |
Question
J'ai trouvé le code que je pense devoir utiliser, mais le problème est qu'il ne fonctionne pas.
Import-Module WebAdministration
$appPools = Get-childItem 'IIS:\AppPools\App Pool'
Set-ItemProperty -Path $appPools -Name recycling.periodicRestart.time -Value 1.00:00:00
Mais j'obtiens cette erreur
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
Je sais que ce n'est pas un problème de chemin.Cela fonctionne.
set-itemproperty -path 'D:\test\TestPS\New Text.txt' -name IsReadOnly -value $true
Toute aide est la bienvenue...
La solution
Il est un problème de chemin.
L'objet revenu de Get-ChildItem 'IIS:\AppPools\App Pool'
est un NodeCollection
objet, et quand vous exécutez Set-ItemProperty -Path $appPools
, $appPools
est étendu à "Microsoft.IIs.PowerShell.Framework.NodeCollection" (qui n'est pas un chemin valide)
Pour modifier les propriétés du pool d'applications :
Set-ItemProperty -Path 'IIS:\AppPools\App Pool' -Name recycling.periodicRestart.time -Value 1.00:00:00
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow