linux远程执行powershel,powershell 远程执行命令(不用手动输入密码)

$user = "domain\usrename"

$password = ConvertTo-SecureString -String "password" -AsPlainText -Force

$credential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $user, $password

$session = New-PSSession -computer ip -credential $credential

$result = Invoke-Command -Session $session -ScriptBlock {Add-PSSnapin vm*}

$result = Invoke-Command -Session $session -ScriptBlock {get-desktopvm -pool_id olanddesk}

$result

连接远程服务器使用

enter-pssession -computer ip -credential domain\username

你可能感兴趣的:(linux远程执行powershel,powershell 远程执行命令(不用手动输入密码))