每次我执行这个命令
invoke-command -computername REMOTEPC -scriptblock { import-module WebAdministration; new-item "$env:systemdrive\inetpub\testsite" -type directory; New-WebSite -Name TestSite -Port 81 -PhysicalPath "$env:systemdrive\inetpub\testsite" }
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
Invalid class string (Exception from HRESULT: 0x800401F3 (CO_E_CLASSSTRING))
+ CategoryInfo : NotSpecified: (:) [Get-ChildItem], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.PowerShell.Commands.GetChildItemCommand
Run Code Online (Sandbox Code Playgroud)
据我所知,该网站已成功创建。
以下命令在枚举 testsite 时给出相同的错误
Invoke-Command -computername REMOTEPC { import-module webadministration; dir -path IIS:\Sites\ }
Name ID State Physical Path Bindings PSComputerName
Default Web Site 1 Started http *:80: REMOTEPC
Invalid class string (Exception from HRESULT: 0x800401F3 (CO_E_CLASSSTRING))
+ CategoryInfo : NotSpecified: (:) [Get-ChildItem], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.PowerShell.Commands.GetChildItemCo
mmand
Run Code Online (Sandbox Code Playgroud)
任何建议,将不胜感激
我和你有同样的问题。我曾尝试创建 16 个站点。第一个正在创建,但有同样的异常...退出迭代,只留下一个创建的网站。我没有修复它,但作为解决方法我添加了
| 输出为空
在线的末尾。这种抑制输出,因此异常被忽略,我的迭代愉快地继续。
就像是:
invoke-command -computername REMOTEPC -scriptblock { import-module WebAdministration; new-item "$env:systemdrive\inetpub\testsite" -type directory; New-WebSite -Name TestSite -Port 81 -PhysicalPath "$env:systemdrive\inetpub\testsite" | out-null}
Run Code Online (Sandbox Code Playgroud)
(注意代码片段末尾的| out-null)
| 归档时间: |
|
| 查看次数: |
4015 次 |
| 最近记录: |