Invoke-Command Problems

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

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 6 years and 1 month 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.
User avatar
mqh77777
Posts: 252
Last visit: Mon Feb 26, 2024 10:07 am
Has voted: 1 time

Invoke-Command Problems

Post by mqh77777 »

Product, version and build: PowerShell Studio 2018 v5.5.149
32 or 64 bit version of product: 64
Operating system: windows 10 and 7
32 or 64 bit OS: 64

In the 2016 version of PowerShell Studio the following code worked.

Invoke-command -ComputerName $SomeMachine -ScriptBlock {
$Output1 = "Remote control of $SomeMachine"
& "\\Server\Share\CmRcViewer.exe" $SomeMachine
$richtextbox_Output.AppendText($output)
}

This calls a Remote Control EXE which in turn allows you to do remote assistance with another user. Yet this exact same code does not work in our current version of PowerShell Studio. And if I run this code within PowerShell ISE it works fine. Did something change in this newer version?
cody m

Re: Invoke-Command Problems

Post by cody m »

What error messages if any are appearing when you run this code? and if there are error messages being displayed can you please screen shot and post them?
User avatar
mqh77777
Posts: 252
Last visit: Mon Feb 26, 2024 10:07 am
Has voted: 1 time

Re: Invoke-Command Problems

Post by mqh77777 »

Hi, nothing gets displayed. I've even tried to add code like this:
$Message1 = " We are now calling the remote assistance .EXE"
$richtextbox_Output.AppendText($Message1)
& "\\server\share\CmRcViewer.exe" $SomeMachine

and I never see it echo out to the RichTextBox. so once it is inside the Invoke-Command { } loop nothing seems to happen.
User avatar
mqh77777
Posts: 252
Last visit: Mon Feb 26, 2024 10:07 am
Has voted: 1 time

Re: Invoke-Command Problems

Post by mqh77777 »

ok, this worked.

$PC = $PCNameBox.Text
$command = "server\share\CmRcViewer.exe"
$argument = $PC
Start-Process $command $argument
cody m

Re: Invoke-Command Problems

Post by cody m »

Great! You can also try

Code: Select all

$x=[pscustomobject]@{Stuff=111}
invoke-command {$x.Stuff = 333} -Computer ws702 
to see if this will work for you
This topic is 6 years and 1 month 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.