powershell - 是否可以在远程计算机上运行 Powershell 脚本?
问题描述
我希望对同一网络中存在的节点运行“IE Rest Script”。
脚本存在于 中,MachineA
并且应该在MachineB
存在于同一网络中的 中执行。
脚本:
add-type -AssemblyName System.Windows.Forms
add-type -AssemblyName microsoft.visualbasic
RunDll32.exe InetCpl.cpl,ResetIEtoDefaults
[Microsoft.VisualBasic.Interaction]::AppActivate("rundll32")
[System.Windows.Forms.SendKeys]::SendWait("{tab}")
[System.Windows.Forms.SendKeys]::SendWait(" ")
[System.Windows.Forms.SendKeys]::SendWait("r")
[System.Windows.Forms.SendKeys]::SendWait("c")
taskkill.exe /f /im iexplore.exe`
解决方案
是的:
Invoke-Command -ComputerName myremotehost.mydomain.tld -ScriptBlock {
# This code here runs on the remote system
}
您必须确保在目标系统上激活了PowerShell Remoting 。
推荐阅读
- crm - 如何在 Suit CRM 中动态填充潜在客户源值?
- c# - 如何使 Random.Range() 步进一定量?
- java - 如何在 xuggler 中将旋转元数据写入视频?
- android - 为什么 AudioManager.setMode(MODE_IN_COMMUNICATION) 背景音乐中断了将近 2 秒?
- php - 日期时间与 AM/PM rconversion 到标准格式到 laravel 5.8 中的数据库
- android - 如何删除 ConstraintLayout 中的空白空间
- javascript - 如何在保持纵横比的文章中创建简单的 3x3 网格?
- python - Django Mysql:MigrationSchemaMissing 错误窗口
- jquery - 将 div 与下一个 div 交换
- python-3.x - 在 pandas 中设置 csv 文件的子集