install module on remote machine

use this script to install powershell module on remote machine

$s = 'server1'



[Net.ServicePointManager]::SecurityProtocol += [Net.SecurityProtocolType]::Tls12

Enter-PSSession -ComputerName $c
 invoke-command -ScriptBlock { Copy-Item -path "\\remote module location\module\PSWindowsUpdate" -Destination "C:\" -Recurse  -force}



        invoke-command -ComputerName $c -ScriptBlock {install-module pswindowsupdate -force}

        #get-module -name PSWindowsUpdate
        invoke-command -ComputerName $c -ScriptBlock {Import-Module "\\remote module location\module\PSWindowsUpdate\PSWindowsUpdate.psm1" -force}
        invoke-command -ComputerName $c -ScriptBlock {get-Module PSWindowsUpdate -force}

        Import-Module "C:\module\PSWindowsUpdate.psm1"

 

Exit mobile version