Working on a script that will go get all AD Computers, filter only the enabled ones, extend the name, loop through and tnc each one, and for only ping succeeded I want to go and check last boot time, and if it’s greater than 7 days I want to send them “Send-NetMessage” to reboot their computers …
$PCs = Get-adcomputer -Filter * | Where {$_.Enabled -eq $true} | Select -Expand Name
Foreach ($PC in $PCs) {
TNC $PC
}
Now I want to select only the PCs that I was able to PING and loop through them to go and Get
Get-CimInstance -ComputerName $PC -ClassName win32_operatingsystem | select csname, lastbootuptime
Select Dates (Get-Date).AddDays(-7)
Then pass the output to another Function Send-NetMessage