Pregunta

Encontré el código que creo que necesito usar, pero la cosa es que no está funcionando.

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

pero estoy recibiendo este 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

Sé que no es un problema de ruta.Esto funciona.

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

Cualquier ayuda sería genial ...

¿Fue útil?

Solución

Es es un problema de ruta.

El objeto devuelto desde Get-ChildItem 'IIS:\AppPools\App Pool' es un objeto NodeCollection, y cuando ejecuta Set-ItemProperty -Path $appPools, $appPools se expande a "microsoft.iis.powershell.framework.nodecollection" (que no es una ruta válida)

Para cambiar las propiedades del grupo de aplicaciones:

Set-ItemProperty -Path 'IIS:\AppPools\App Pool' -Name recycling.periodicRestart.time -Value 1.00:00:00

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top