I want to execute powershell commands on a remote computer and I use a extern Module on the localhost. I tested it and get the message that I don't can use the command on the remote computer but locally it works.
So I have installed the module on the remote computer via Import-Module and it works.
But this is bad and I want not install the module on every computer in the company.
Here is my PS Script:
$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..."
}
Before I run this script I have do this:
Enable-PSRemoting -Force
Set-Item WSMan:\localhost\Client\TrustedHosts * -Force #for testing
Restart-Service WinRM
So how I can execute extern module commands without install it on the remote computer? :/
You can import a module from a shared location (if your execution policy allows it):
but you can't run a function from a module without importing the module first.