Stefan Spiroski
Stefan Spiroski

Reputation: 23

PowerShell remote session

Sorry if this was asked before, but i don't know why the same command acts differently. I executed the following command on the local machine Invoke-Command -ComputerName servername -Credential username@domainname {Get-HotFix | Sort-Object -Descending InstalledOn | Select-Object HotFixID} and got the following output:

HotFixID  PSComputerName RunspaceId                          
--------  -------------- ----------                          
KB3084905 servername    25412368-2543-2541-3258-254687qw25rt
KB3102429 servername    25412368-2543-2541-3258-254687qw25rt
KB3004545 servername    25412368-2543-2541-3258-254687qw25rt
KB4576486 servername    25412368-2543-2541-3258-254687qw25rt
KB4576489 servername    25412368-2543-2541-3258-254687qw25rt

but if i execute the same command Get-HotFix | Sort-Object -Descending InstalledOn | Select-Object HotFixID directly on the server i get

HotFixID 
-------- 
KB3084905
KB3102429
KB3004545
KB4576486
KB4576489

How can i get the same output when using the Invoke-Command?

Upvotes: 1

Views: 62

Answers (1)

Stefan Spiroski
Stefan Spiroski

Reputation: 23

Well after posting i solved my question. I just needed to run this command to print the same output Invoke-Command -ComputerName servername -Credential username@domainname {Get-HotFix | Sort-Object -Descending InstalledOn} -HideComputerName | Select-Object HotFixId

Upvotes: 1

Related Questions