Question

basically I want to do this:

foreach ($SERVER_NAME in $SERVER_NAME_LIST)
{

$SESSION = New-PSSession -ComputerName $SERVER_NAME -Credential $CRED
Invoke-Command -Session $SESSION -ScriptBlock 
{   
    Write-Zip -Path $PATH -OutputPath test.zip -IncludeEmptyDirectories
}
}

I get this error:

The term 'Write-Zip' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Do I really have to install the extension on everey remote maschine and invoke the import module every time?

Thanks in advance for your help

Was it helpful?

Solution

yes, you need to install on each remote machine, as the invoke-command will run the commond on the remote machine. If you are using Powershell v3, you do not need to import manually, as PSV3 could import module automatically, but if you are using powershell-v2, you need to import in the -scriptblock {ipmo path\to\module}

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top