More sample PS one-liners for Std_Out GUI

Started by spl, July 13, 2026, 07:59:50 AM

Previous topic - Next topic

spl

just for practice, but script works. There are literally 20-30 PS one-liners that reduce admin chores.
;Sample PS One-Liners for STd_Out Function
;
;The PS Out-Gridview is a neat addition to admin one-liners
; In the code below you can choose to comment/uncomment on of the sample args variable 
; in order to view the GUI output. 
; These were tested in both WB 32/64 bit, using PS 5.1 install (pretty much in Win10/11 OS)
; The Gridview permits Ctrl-C,Ctrl-A for Clipboard use.
;
;Script ends up with a GridView
;Stan Littlefield 7/13/2026
;
;save as Std_out.OneLiners.wbt
;========================================================================================================================
Gosub udfs

;Sample 1
args = "Get-Service | Where-Object {$_.status -eq 'Running'} | Out-GridView -Title 'Started Services' -PassThru"

;Sample 2
;args = "Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Out-Gridview -Title 'Registry Uninstall' -PassThru"

cmd="Powershell"
msg='Extended Computer Information'
BoxOpen("Running...",cmd:" ":args:@LF:"PLEASE WAIT...MAY TAKE SOME TIME")
TimeDelay(3)
vals = Get_stdout()
Exit
;======================================================================
:udfs
#DefineSubroutine Get_stdout()
ObjectClrOption("useany","System")
objInfo = ObjectClrNew("System.Diagnostics.ProcessStartInfo")
Output=""
timeOut = ObjectType("I2",5000)
objInfo.FileName = cmd
objInfo.RedirectStandardError = ObjectType("BOOL",@TRUE)
objInfo.RedirectStandardOutput = ObjectType("BOOL",@TRUE)
objInfo.UseShellExecute = ObjectType("BOOL",@FALSE)
objInfo.CreateNoWindow = ObjectType("BOOL",@TRUE)
objInfo.Arguments = args
oProcess = ObjectClrNew("System.Diagnostics.Process")
oProcess.StartInfo = objInfo
BoxShut()
oProcess.Start()
oProcess.WaitForExit(timeout)
STDOUT = oProcess.StandardOutput.ReadToEnd()
STDERR = oProcess.StandardError.ReadToEnd()
Output = Output:STDOUT:@CRLF
If STDERR<>""
   Output = Output:"STDERR:":STDERR:@CRLF
Endif
oProcess = 0
objInfo = 0

Return (Output)
#EndSubroutine
Return
;==========================================================
Stan - formerly stanl [ex-Pundit]

td

You will have your own section in the Tech Database eventually. At least for the scripts that get copied before you delete them.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

spl

Quote from: td on July 13, 2026, 09:34:47 AMYou will have your own section in the Tech Database eventually. At least for the scripts that get copied before you delete them.

I only delete that which has not been acknowledged. Even a 'this sucks' would suffice.
Stan - formerly stanl [ex-Pundit]

SMF spam blocked by CleanTalk