$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
时间: 2024-10-13 03:37:47