首页 > 系统服务 > 详细

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

时间:2016-08-05 18:01:44      阅读:210      评论:0      收藏:0      [点我收藏+]

$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


本文出自 “备忘录” 博客,请务必保留此出处http://flybozhou.blog.51cto.com/818675/1834767

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

原文:http://flybozhou.blog.51cto.com/818675/1834767

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!