tag:blogger.com,1999:blog-7735540253912387734.post7372367115350298740..comments2024-03-18T15:02:19.805+01:00Comments on Being a Windows System Administrator: [Powershell] How to annoy your users to restart their computers more oftenUnknownnoreply@blogger.comBlogger3125tag:blogger.com,1999:blog-7735540253912387734.post-17261398671136681412024-03-18T15:02:19.805+01:002024-03-18T15:02:19.805+01:00Any chance you've updated this? It sounds simp...Any chance you've updated this? It sounds simple and great, just what a I need.<br />Got some errors testing the ps script on my win 11 23h2<br />Thank you!Doughttps://www.blogger.com/profile/13786214555990006751noreply@blogger.comtag:blogger.com,1999:blog-7735540253912387734.post-87441985050992634702021-10-05T02:09:56.572+02:002021-10-05T02:09:56.572+02:00I would love to use this! When I save as .ps1 and ...I would love to use this! When I save as .ps1 and run on my machine I get this error:<br /><br />Any ideas on how I can fix this or perhaps what I am doing wrong?<br /><br />Cannot index into a null array.<br />At C:\Users\xx\downloads\test-restart-script.ps1:96 char:1<br />+ $user = $matches[1]<br />+ ~~~~~~~~~~~~~~~~~~~<br /> + CategoryInfo : InvalidOperation: (:) [], RuntimeException<br /> + FullyQualifiedErrorId : NullArray<br /><br />Cannot index into a null array.<br />At C:\Users\xx\downloads\test-restart-script.ps1:97 char:1<br />+ $last_logon = $matches[2]<br />+ ~~~~~~~~~~~~~~~~~~~~~~~~~<br /> + CategoryInfo : InvalidOperation: (:) [], RuntimeException<br /> + FullyQualifiedErrorId : NullArray<br /><br />New-TimeSpan : Cannot bind parameter 'Start'. Cannot convert value "â€Start ([datetime]::ParseExact(, 'dd.MM.yyyy HH:mm', )) -End (Get-Date))<br /># Determine system's last boot time from CIM<br /># ATTENTION: Systems with a depleted CMOS battery will likely contain a wrong value here and users might call and ask why their computer thinks it was last booted over 2000<br />days ago.<br /># ATTENTION: While the system time gets updated by NTP some time after booting the value in CIM will stay wrong. Replace the CMOS battery to fix the issue.<br /> = (Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object LastBootUpTime).LastBootUpTime<br /> = (New-TimeSpan â€Start" to type "System.DateTime". Error: "The string was not recognized as a valid DateTime. There is an unknown word starting at index 0."<br />At C:\Users\xx\downloads\test-restart-script.ps1:100 char:38<br />+ ... ew-TimeSpan –Start ([datetime]::ParseExact($last_logon, 'dd.MM.yyyy ...<br />+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br /> + CategoryInfo : InvalidArgument: (:) [New-TimeSpan], ParameterBindingException<br /> + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.NewTimeSpanCommand<br /><br />Anonymoushttps://www.blogger.com/profile/11252792793400681750noreply@blogger.comtag:blogger.com,1999:blog-7735540253912387734.post-78942772513786319862019-04-24T08:43:10.482+02:002019-04-24T08:43:10.482+02:00Nice one! I'll be trying to implement this :DNice one! I'll be trying to implement this :DDariohttps://www.blogger.com/profile/01552303100304402140noreply@blogger.com