Powershell远程执行命令
程序员文章站
2023-12-30 15:03:22
...
$Username = 'xx'
$Password = 'xx'
$ComputerName='xx'
$pass = ConvertTo-SecureString -AsPlainText $Password -Force
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass
Invoke-Command -ComputerName $ComputerName -ScriptBlock { Restart-Computer -Force
} -credential $Cred