Link to home
Start Free TrialLog in
Avatar of Matthew Eilers
Matthew Eilers

asked on

Powershell Output does not display when run on remote PC

I wrote a simple script to display installed programs. It works on the local machine just fine - grabs the programs, lists them alphabetically, great. When I try to run it on a remote PC, the script finishes but there is no output. No error, but nothing displayed. I tried putting Write-Host in various places, but no joy. I would like to be able to retrieve this information without having to write it to a file on the local machine, and then open the file to read the info. Any hints? Also not sure if the invoke-command is needed.


$Computername = Read-Host -prompt ("Which PC would you like to Inventory installed software on?")
$Credential = Read-Host -prompt ("What domain and username would you like to Authenticate with?")
$s = New-PSSession -ComputerName $Computername -Credential $Credential
Invoke-Command -Session $s -ScriptBlock {Get-WMIObject -Class Win32_Product -Computername $Computername | Sort name | Format-Wide -Column 1 -passthru}
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Matthew Eilers
Matthew Eilers

ASKER

Thank you for you input guys. Unfortunately -passthru is not being recognized as a usable parameter in this version.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Correct, I should have removed that switch ...
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Split:
-- Qlemo (https:#a42429319)
-- footech (https:#a42429416)
-- Matthew Eilers (https:#a42430579)


If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

Pber
Experts-Exchange Cleanup Volunteer