Skip to content

Instantly share code, notes, and snippets.

@ctigeek
Created November 2, 2015 14:02
Show Gist options
  • Select an option

  • Save ctigeek/28bb4ce00c9d75a0accf to your computer and use it in GitHub Desktop.

Select an option

Save ctigeek/28bb4ce00c9d75a0accf to your computer and use it in GitHub Desktop.
function Copy-WUPowershellModule($computerName) {
$remotePath = "\\$($computerName)\c$\Windows\System32\WindowsPowerShell\v1.0\Modules\PSWindowsUpdate"
$localPath = "C:\Windows\System32\WindowsPowerShell\v1.0\Modules\PSWindowsUpdate"
if (! (Test-Path $remotePath )) {
Write-Host "Copying powershell module."
Copy-Item $localPath -Destination $remotePath -Recurse -Force
}
$command = {
##Add the Microsoft Update service
Add-WUServiceManager -ServiceID 7971f918-a847-4430-9279-4a52d1efe18d -Confirm:$false
}
Invoke-Command -ComputerName $computerName -ScriptBlock $command
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment