$uname="administrator" #administrator为用户名
$pwd=ConvertTo-SecureString "111111" -AsPlainText -Force; #111111为密码
$cred=New-Object System.Management.Automation.PSCredential($uname,$pwd); #创建自动认证对象
$pcname="192.168.44.129"
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是用来执行脚本文件中的命令
通过powershell remoting自动登录服务器
最新推荐文章于 2024-02-06 09:14:36 发布