欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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  

 

上一篇:

下一篇: