Quantcast
Viewing all articles
Browse latest Browse all 311

PowerShell GUIs • nothing within a script block executes

Product: PowerShell Studio 2023 (64 Bit)
Build: v5.8.232
OS: Windows 11.0.22631
PS Version(s): 5.1.22621.1, 7.4.2


I have this simple code. the $statusbar text only works outside of the Invoke-Command -Scriptblock. Why? I need to have a few commands run within the Invoke-Command that run on the remote machine, where $PC=$PCNameBox.Text can be any system in your environment that you have access too. But so far nothing within the Invoke-Command runs.

Code:

$buttonExecuteAllCommands_Click = {$PC = $PCNameBox.Text$richtextbox.Clear()$statusbar1.text = 'Running commands, please wait.'Start-Sleep -Seconds 3Invoke-command -ComputerName $PC -ScriptBlock {$statusbar1.text = 'Running commands, please wait.'Start-Sleep -Seconds 3$statusbar1.text = 'All done!'}$statusbar1.text = 'All done!'}

Statistics: Posted by mqh77777 — Sat Apr 27, 2024 11:37 am — Replies 0 — Views 19



Viewing all articles
Browse latest Browse all 311

Trending Articles