【发布时间】:2015-06-24 09:05:40
【问题描述】:
我想在远程计算机上执行 powershell 命令,我在本地主机上使用了一个外部模块。我对其进行了测试并得到消息,我不能在远程计算机上使用该命令,但在本地它可以工作。
所以我已经通过 Import-Module 在远程计算机上安装了模块并且它可以工作。
但这很糟糕,我不想在公司的每台计算机上都安装该模块。
这是我的 PS 脚本:
$cred = Get-Credential
$isConnect = Test-WSMan edv-004
if($isConnect){
#Get-WUHistory is from a extern Module and list the Updatehistory of a computer
Invoke-Command -ComputerName edv-004 -ScriptBlock { Get-WUHistory } -Credential $cred
Write-Host "Skript wurde auf ausgeführt..."
}
在我运行这个脚本之前,我已经这样做了:
Enable-PSRemoting -Force
Set-Item WSMan:\localhost\Client\TrustedHosts * -Force #for testing
Restart-Service WinRM
那么我如何在不安装在远程计算机上的情况下执行外部模块命令呢? :/
【问题讨论】:
标签: powershell updates remote-access execute winrm