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}
PowershellSoftwareShell ScriptingPC

Avatar of undefined
Last Comment
Pber

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Qlemo

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
footech

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Matthew Eilers

ASKER
Thank you for you input guys. Unfortunately -passthru is not being recognized as a usable parameter in this version.
SOLUTION
Matthew Eilers

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Qlemo

Correct, I should have removed that switch ...
Pber

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
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck