Reboot message pc when not rebooted 30 days
Hi,

I would like to:

1.send a message to pc's which have not rebooted for 30 days (collection exists) and force them to

reboot.
2.send a message to pc's which have a pending reboot (collection exists) and didn't reboot for 1

week.

Therefore I tested this simple powershell, sent via an application:

$wshell = New-Object -ComObject Wscript.Shell
$wshell.Popup("Your pc hasn't rebooted for 30 days. `r`n `r`n A reboot will be forced within 12 hours

as from now.",0,"Reboot Message")

That works fine, users get a popup. I trigger a forced reboot afterwards and use this as detection method for the first scenario:

$boottime = Get-CimInstance -ClassName win32_operatingsystem | select lastbootuptime -ExpandProperty

lastbootuptime
$boottime -ge (get-date).AddDays(-30)

The second scenario, I can find my way.

It looks like everything is working well but before implementing it, would like your feedback and meanwhile sharing it (might come in handy for other users).

September 3rd, 2015 10:05am

Read this page (never tested it)

http://www.systemcentercentral.com/sccm-collection-query-computers-with-pending-restart-or-other-update-enforcement-states/

You will see how to make a collection with computer that have reboot pending. From that point on you can than apply the same script and just change the text.

Not sure i would go for this. I mean does it matter something if the computer have not reboot in more than 30 days?

Also if you need to reboot computer that have a pending reboot you should ask yourself WHY is this happening and maybe prevent it from happening.




Free Windows Admin Tool Kit Click here and download it now
September 3rd, 2015 10:07am

Maybe another way would be to add a daily scheduled task that shuts down or restarts the computer in the early hours. That would help getting all of your devices compliant rather than having to wait x amount of days.
September 3rd, 2015 10:19am

Read this page (never tested it)

http://www.systemcentercentral.com/sccm-collection-query-computers-with-pending-restart-or-other-update-enforcement-states/

You will see how to make a collection with computer that have reboot pending. From that point on you can than apply the same script and just change the text.

Not sure i would go for this. I mean does it matter something if the computer have not reboot in more than 30 days?

Also if you need to reboot computer that have a pending reboot you should ask yourself WHY is this happening and maybe prevent it from happening.




  • Edited by Frederick Dicaire Thursday, September 03, 2015 2:09 PM
  • Marked as answer by janhoedt 18 hours 15 minutes ago
  • Unmarked as answer by janhoedt 16 hours 42 minutes ago
Free Windows Admin Tool Kit Click here and download it now
September 3rd, 2015 2:06pm

Read this page (never tested it)

http://www.systemcentercentral.com/sccm-collection-query-computers-with-pending-restart-or-other-update-enforcement-states/

You will see how to make a collection with computer that have reboot pending. From that point on you can than apply the same script and just change the text.

Not sure i would go for this. I mean does it matter something if the computer have not reboot in more than 30 days?

Also if you need to reboot computer that have a pending reboot you should ask yourself WHY is this happening and maybe prevent it from happening.




  • Edited by Frederick Dicaire Thursday, September 03, 2015 2:09 PM
  • Marked as answer by janhoedt Friday, September 04, 2015 1:38 PM
  • Unmarked as answer by janhoedt Friday, September 04, 2015 3:11 PM
September 3rd, 2015 2:06pm

Maybe another way would be to add a daily scheduled task that shuts down or restarts the computer in the early hours. That would help getting all of your devices compliant rather than having to wait x amount of days.
Free Windows Admin Tool Kit Click here and download it now
September 3rd, 2015 2:18pm

Scheduled task is not an option. Most computers are laptops so not online during early hours. Then others go to sleep so we'd have to wake them remotely.
September 4th, 2015 7:58am

Actually my script isn't working.

If the pc is rebooted, it will be considered as installed and nothing will happen, what is ok.

It is not considered as installed when the pc isn't rebooted for 30 days, so it will install it (show the popup) but after that it still won't be considered as installed since it hasn't rebooted so it will fail and no reboot is triggered.

Please advise.


Free Windows Admin Tool Kit Click here and download it now
September 4th, 2015 11:16am

Thanks, but collection queries I already have/had and were working fine.
September 4th, 2015 11:16am

I know it's not quite what you asked but I like the Coretech Shutdown Utility

http://blog.coretech.dk/kea/configuration-manager-shutdown-utility/

Free Windows Admin Tool Kit Click here and download it now
September 4th, 2015 12:47pm

How exactly have you setup your deployment?
September 4th, 2015 12:54pm

I have deployed the powershell to a computercollection which queries pc's which have not rebooted for 30 days (with forced reboot afterwards).
The powershell with message is deployed and an application with detectin method:

$boottime = Get-CimInstance -ClassName win32_operatingsystem | select lastbootuptime -ExpandProperty
lastbootuptime
$boottime -ge (get-date).AddDays(-30)

So if the detection method = false, the powershell should run = show message.
After that a reboot is forced.

Free Windows Admin Tool Kit Click here and download it now
September 7th, 2015 4:50am

Thanks Gerry, I like the tool but can't use it since it is pretty unprofessional to have this ugly interface in it filled with CoreTech publicity.
September 7th, 2015 5:08am

Maybe I could use the shutdown tool from Microsoft: https://technet.microsoft.com/en-us/library/bb491003.aspx then however I'm still stuck with the detection method.
First time it will copy the exe, then trigger a reboot but second time it will see the exe and not run since it's already installed.

Maybe I should consider a package instead of an application?

Free Windows Admin Tool Kit Click here and download it now
September 7th, 2015 5:13am

Right, I think a package is the way to go. It's the only way we can just launch it without any further concerns.

So what I'm doing now is deploying a package which runs reboot.ps1 to the colleciton with pc's which have not rebooted for 30 days.

This shows a popup:
$wshell = New-Object -ComObject Wscript.Shell
$wshell.Popup("Your pc hasn't rebooted for 30 days. `r`n `r`n A reboot will be forced within 12 hours

And wil force the sccm client to do a reboot.

What my concern now is, is that the client will stay to long in the collection and a new reboot will be triggered.

September 7th, 2015 5:22am

Jan,

the interface can be customized with your own logo, text, color etc. It's being used my 1000's - calling it unprofessional might be a little to much :-)

Free Windows Admin Tool Kit Click here and download it now
September 7th, 2015 5:45am

Sorry, wasn't meant offensive. The exe itself is great, it's only the interface which is a bit basic. I didn't know it could be customized though (I did see the some jpgs but I guess the text will always stay there?)
September 7th, 2015 5:51am

Fully customizable, great solution. Thanks Kent!
Free Windows Admin Tool Kit Click here and download it now
September 7th, 2015 6:07am

Ant thanks Gerry!
September 7th, 2015 6:08am

have you considered using Orchestrator to work with this, you could get the collection, work with that collection (by pushing a reboot to each machine) and then empty the collection.

for your scenario, I would suggest that Orchestrator would be a good way to go, however the downside here is that you need to get at least 1 VM for the orchestration console and have a orchestrator DB sitting somewhere.  


Free Windows Admin Tool Kit Click here and download it now
September 7th, 2015 12:45pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics