Help with System.Management.Automation.PSRemotingJob error

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 3 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
shiroscout
Posts: 41
Last visit: Sat Jul 15, 2023 7:13 pm

Help with System.Management.Automation.PSRemotingJob error

Post by shiroscout »

Hello,

I am getting an error when debugging and have no idea what is causing it.
ERROR: System.Management.Automation.PSRemotingJob
ERROR: At Line: 1 char: 1

I believe I get the error when clicking the button "Get PC Info"

I'm a bit concerned, as I just updated .net, did a Windows Update, and installed several other programs and modules for Electron, and Powershell so I am not sure if these things might have dome something.
Do you need any other log files or anything?

I might also be to blame, and I need to know about the assembly files because I tried pointing Powershell Studio to the newer files. But I do not have any of those files listed in my script or the lines that start with VOIDxxx

Product: PowerShell Studio 2020 (64 Bit)
Build: v5.7.174
OS: Windows 10 Pro (64 Bit)
Build: v10.0.18363.0
Thank You,

Wayne
Attachments
ShiroScout.jpg
ShiroScout.jpg (52.06 KiB) Viewed 3247 times
First Script checking and debugging help.pdf
(126.99 KiB) Downloaded 113 times
Thank You,

Wayne
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Help with System.Management.Automation.PSRemotingJob error

Post by jvierra »

PS 6 is likely the cause. Please try running this under PS 5.1 and the error will likley disappear.

PS 6 does not fully support remoting.
User avatar
shiroscout
Posts: 41
Last visit: Sat Jul 15, 2023 7:13 pm

Re: Help with System.Management.Automation.PSRemotingJob error

Post by shiroscout »

I checked and that does not seem to be an issue. Here is my Powershell version info:
PS C:\Windows\system32> $PSVersionTable

Name Value
---- -----
PSVersion 5.1.18362.752
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.752
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Thank You,

Wayne
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Help with System.Management.Automation.PSRemotingJob error

Post by jvierra »

What version did you select in PowerShell Studio?

Have you tried running this script form a PS prompt and not in PowerShell Studio?
User avatar
shiroscout
Posts: 41
Last visit: Sat Jul 15, 2023 7:13 pm

Re: Help with System.Management.Automation.PSRemotingJob error

Post by shiroscout »

Here is my fix. I was using Start-Job and got rid of it as I was using it incorrectly, as I am only using this on local machine, and I think it was calling the psremoting which I did not need.

I changed my code from this:

Code: Select all

$Command = Start-Job -ScriptBlock { Systeminfo -fo "LIST" | Format-List | Out-String }
	$Script = (Systeminfo -fo "LIST" | Format-List | Out-String)
	Invoke-Expression -Command $Command
	$richtextbox1.Text = ($Script)
to this

Code: Select all

$buttonCollectPCInformation_Click = {
	$Command = { Systeminfo -fo "LIST" | Format-List | Out-String }
	$Script = (Systeminfo -fo "LIST" | Format-List | Out-String)
	Invoke-Command -ScriptBlock $command
	$richtextbox1.Text = ($Script)
}
Issue is Fixed and Resolved.
Thank You,

Wayne
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Help with System.Management.Automation.PSRemotingJob error

Post by jvierra »

Doesn't seem to have anything to do with your question. "SystemInfo in a pipeline with FOrma-list makes no sense. The output of systeminfo is text and not objects.

There is no reason for you t use Invoke-Command here. Just run systeminfol

This is all you need to do:

Code: Select all

$buttonCollectPCInformation_Click = {
	$richtextbox1.Text = Systeminfo -fo LIST
}
You are making a mistake common to all new users of PowerShell, You are writing too many lines of code that do nothing except make the task harder. Take time to understand each step and test each step at a prompt until you understand what it does.
User avatar
shiroscout
Posts: 41
Last visit: Sat Jul 15, 2023 7:13 pm

Re: Help with System.Management.Automation.PSRemotingJob error

Post by shiroscout »

Hello, Yes friend, you are correct. I overdid it and made it way too hard on myself. I don't know how many hours I worked on getting it corrected, and then I used your code and it immediately did what I needed with no PowerShell flash popup, etc...
That worked exactly as I needed with 90% less code. :)
Thank You,

Wayne
User avatar
shiroscout
Posts: 41
Last visit: Sat Jul 15, 2023 7:13 pm

Re: Help with System.Management.Automation.PSRemotingJob error

Post by shiroscout »

I'll use your good suggestion of trying commands, etc... one-at-a-time, and see what they do, and see if that works as needed without plumping up my code needlessly.

Thank You again.

Wayne
Thank You,

Wayne
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Help with System.Management.Automation.PSRemotingJob error

Post by jvierra »

I suggest that means it is time for you to learn PowerShell. You can see how much time and effort it will save you.

Start here: https://www.sapien.com/books_training/W ... werShell-4
User avatar
shiroscout
Posts: 41
Last visit: Sat Jul 15, 2023 7:13 pm

Re: Help with System.Management.Automation.PSRemotingJob error

Post by shiroscout »

Well I suppose you are correct.
Awesome, thank you. You should include a link to this free book with every Sapien product purchase. It might save you from many migraine headaches and support mayhem. :)
Thank you again.
Wayne
Thank You,

Wayne
This topic is 3 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked