无法创建新的New-CimInstance

时间:2019-02-04 18:49:13

标签: powershell powershell-remoting

我正在尝试远程停止/启动Windows服务。但是,如果删除-Computer参数,则它在本地计算机上运行良好。如果添加-Computer参数,它将引发异常。我想念什么吗?

New-CimInstance : Unable to resolve the parameter set name.
At D:\DevOps\Scripts\StartStopvNextService.ps1:6 char:16
+ ... yInstance = New-CimInstance -Namespace root/cimv2 -ClassName Win32_En ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [New-CimInstance], PSArgumentException
    + FullyQualifiedErrorId : Argument,Microsoft.Management.Infrastructure.CimCmdlets.NewCimInstanceCommand
Param(
    [string]$Name,
    [string]$Computer
)
Import-Module CimCmdlets
$keyInstance = New-CimInstance -Namespace root/cimv2 -ClassName Win32_Service -Key @('Name') -Property @{Name=$Name;} -ComputerName $Computer -ClientOnly

Invoke-CimMethod $keyInstance -MethodName StartService

0 个答案:

没有答案