尝试将Set-ItemProperty与DefaultAppPool一起使用时出现Powershell错误

Mar*_*pan 3 powershell scripting

我试着做这里的答案:在使用New-WebAppPool时如何设置.NET Framework版本?

并使用命令:

Set-ItemProperty C:\inetpub\temp\appPools\DefaultAppPool managedRuntimeVersion v4.0
Run Code Online (Sandbox Code Playgroud)

但是我得到了这个错误

Set-ItemProperty:属性System.String managedRuntimeVersion = v4.0不存在.在行:1 char:17 + Set-ItemProperty <<<< C:\ inetpub\temp\appPools\DefaultAppPool managedRuntimeVersion v4.0 + CategoryInfo:ReadError:(System.String managedRuntimeVersion = v4.0:PSNoteProperty)[IOException + FullyQualifiedErrorId :SetPropertyError,Microsoft.PowerShell.Commands.SetItemPropertyCommand

我认为我正确加载了Web管理模块(右键单击任务栏图标并选择"导入系统模块"然后尝试了该shell中的命令)并且我也尝试使用该命令并明确说明参数,它仍然发生.与AutoStart等其他属性同样存在问题.

有谁知道我可能做错了什么?

And*_*ndi 5

C:\是来自文件系统提供者.Keith在您链接的SO问题中的答案是使用IIS提供程序IIS:\.

Set-ItemProperty IIS:\AppPools\<pool_name> managedRuntimeVersion v4.0
Run Code Online (Sandbox Code Playgroud)