嗨,我是 power shell 的新手,我似乎无法让这个脚本运行它是在工作组中的计算机上使用命令提示符远程执行命令这是我得到脚本的错误如下我正在运行脚本一台win 7机器我想远程执行的机器是windows xp sp3防火墙关闭并且com设置设置为默认的身份验证设置和识别模拟和帮助会很棒
这是错误 Invoke-WmiMethod :访问被拒绝。(来自 HRESULT 的异常:0x80070005 (E_ACCESSDENIED))在 C:\Users\Kevin\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:57 char:40 + $newproc = Invoke-WmiMethod <<<< -class Win32_process -name Create ` + CategoryInfo : NotSpecified: (:) [Invoke-WmiMethod], UnauthorizedAccessException + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.InvokeWmiMethod
$command = Read-Host " Enter command to run"
$user = "\Administrator"
$Domainname = $HostName +$user
$login = Get-Credential $domainname
[string]$cmd = "CMD.EXE /C " +$command
}
process {
$newproc = Invoke-WmiMethod -class Win32_process -name Create `
-ArgumentList ($cmd) -EnableAllPrivileges -ComputerName $HostName -authentication Packetprivacy -Impersonation 3 -Credential $login
if ($newproc.ReturnValue -eq 0 )
{ Write-host -foregroundcolor Green "Command $($command) Ran Sucessfully on $($HostName)"}