I moved adaxes to a new virtual server (2022), upgraded powershell, and upgraded to 2025.1 so working through script issues. This script retrieves the last reboot for computers and now I get this error:
The term 'gwmi' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. Stack trace: at <ScriptBlock>, <No file>: line 1
When I run the script in powershell ise as my svcAdaxes user on the Adaxes server, it works.
$resultobj = gwmi win32operatingsystem -ComputerName %name% | select csname, @{LABEL='LastBootUpTime';EXPRESSION={$.ConverttoDateTime($_.lastbootuptime)}}
$logmessage = $resultobj | Out-String -Stream
foreach ($logline in $logmessage) { if ($logline -ne '') { $Context.LogMessage($logline, "Information") } }
$RebootTime = New-TimeSpan -Start $resultobj.LastBootUpTime -End (Get-Date)
$logmessage = 'The system was last restarted (' + $RebootTime.Days + ') days ago.'
$Context.LogMessage($logmessage, "Information")