点击脚本,远程执行文件!

我终于做到了T-T

执行远程脚本,

这一刻,我花了半年......

德玛西亚!



大致思路:

$passwd = "Demacia!!!!"
$sePasswd = ConvertTo-SecureString $passwd -AsPlainText -Force
$cred=New-Object System.Management.Automation.PSCredential("administrator",$sePasswd)
$s = New-PSSession -ComputerName 192.168.1.9 -Credential $cred
invoke-command -session $s -scriptblock {cd C:\Users\administrator\Desktop;cscript write.vbe}
另存为ps1文件,使用powershell打开即可。

当然,之前目标机器必须要先打开WinRM服务,具体看此处:

#使本机器可以执行ps1文件  
set-executionpolicy remotesigned  
#是否要通过本计算机上的 WinRM 服务启用远程管理?  
Set-WSManQuickConfig  
#关闭防火墙  
Enable-PSRemoting –Force  
#添加信任IP  
cd wsman::localhost\client  
Set-Item TrustedHosts "10.2.1.9"  
#远程该IP  
Enter-PSSession -ComputerName 10.2.1.9 –Credential Administrator  


以上。感谢您的阅读。欢迎给我评论。


参考文档:

http://www.cnblogs.com/dreamer-fish/p/3989899.html 该文讲了一些密码加密的知识

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值