... and just for fun

Started by spl, September 26, 2026, 09:22:34 AM

Previous topic - Next topic

spl

I noticed a 2009 script I wrote about Restore Points is in the Tech DB. Things have changed since then and maybe not so much code needed. The Std_Out script below will perform a simple display or any restore points, or show nothing if there are not any. I was surprised my Surface Pro shows to 'checkpoints' so wonder if anyone else has them. But an interesting point is this: as written the script displays the properties as a table, with the Created element translated to [datetime]: .net variable. Note there are two '##' in the args= .... delete them and rerun the script and you will get Json output, but curious the Created element is now set as both a value and a translation. Guess PS takes Json seriously....
;Std_Out Restore Points
;Stan Littlefield 9/26/2026
;========================================================================================================================
Gosub udfs
args = $"Get-ComputerRestorePoint | Select Description, SequenceNumber, RestorePointType,
@{n='Created';e={[System.Management.ManagementDateTimeConverter]::::ToDateTime($_.creationtime)}} ##| ConvertTo-Json
$"

cmd="Powershell"                                                                                                       
msg='Restore Points'
BoxOpen(msg,cmd:" ":args:@LF:"PLEASE WAIT...MAY TAKE SOME TIME")
TimeDelay(2)
vals = Get_stdout()
BoxShut()
Message("Restore Points",vals)
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
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]

SMF spam blocked by CleanTalk