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).
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 17 hours 41 minutes ago
- Edited by Richard.Knight 17 hours 31 minutes ago
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
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
- Edited by Richard.Knight Thursday, September 03, 2015 2:19 PM
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.
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/
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.
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?
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.
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 :-)
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.