24cun_cn 发表于 2018-9-2 07:35:50

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

页: [1]
查看完整版本: powershell 远程执行命令(不用手动输入密码)