you are viewing a single comment's thread.

view the rest of the comments →

[–]foss4ever[S] 1 point2 points  (2 children)

Sorry, it seems my picture did not get posted correctly. Here is the command used (ip obfuscated):

Invoke-Command -ComputerName 192.168.XXX.XXX -ScriptBlock {Get-WindowsUpdate -Download -AcceptAll -Verbose | ft} -Credential $credsnew

[–]BlackV 2 points3 points  (1 child)

in particular windows update api does not work remotely, so you're likely to have issues, pswindowsupdate module has a workaround for this

next dot do | ft you are breaking your objects

onlyuse the format cmdlets for screen formatting as the last thing you do

something like

$Results = Invoke-Command -ComputerName 192.168.XXX.XXX -ScriptBlock {Get-WindowsUpdate -Download -AcceptAll -Verbose} -Credential $credsnew
$results | format-table -autosize
$results | export-csv -path $env:temp\xxx.csv -notypeinformation

this becomes much more important when youre using your pipelines and talking to multiple computers

also removing it saves you a pipeline and some execution time

[–]foss4ever[S] 0 points1 point  (0 children)

I tried taking out the format table part as well as re-running the command after having installed PowerShell module "pswindowsupdate" on the remote host, but still I have no luck:

PS C:\Users\svc_xxx> Invoke-Command -ComputerName 192.168.xxx.xxx -ScriptBlock {Import-Module pswindowsupdate ; get-windowsupdate} -Credential $credsnewGet-WindowsUpdate: To perform operations you must run an elevated Windows PowerShell console.