Powershell远程登录脚本

阿里云代金券1888元免费领取地址:https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=gpccyg1q
新老阿里云账户均可领取!可用于购买阿里云服务器ECS、云数据库RDS、虚拟主机、安骑士、DDoS高防IP等100多云计算产品。 代金券是有有效期的,请及时使用,过期后还可以重新领取。

$uname="administrator" #administrator为用户名

$pwd=ConvertTo-SecureString "111111" -AsPlainText -Force#111111为密码

$cred=New-Object System.Management.Automation.PSCredential($uname,$pwd); #创建自动认证对象

$pcname="192.168.1.1"

Enter-PSSession -ComputerName $pcname -Credential $cred #登录

"This is an autolink script which generates auto login feature!"

#Invoke-Command -scriptblock {ipconfig} -Credential $cred -ComputerName $pcname #-scriptblock是用来执行单个命令

#Invoke-Command -FilePath C:\runme.ps1 -Credential $cred -ComputerName $pcname #-filepath是用来执行脚本文件中的命令

 

这个可以用在jenkins下做windows服务器自动登陆脚本。

猜你喜欢

转载自www.cnblogs.com/ksbuy/p/10075724.html