Menu

Tree [ea00bd] master / util-winStartup /
 History

HTTPS access


File Date Author Commit
 Get-StartupInfoToCSV.PS1 2019-05-29 theitguys theitguys [00796e] setting up new repo
 ReadMe.txt 2019-05-29 theitguys theitguys [00796e] setting up new repo
 Set-AutoLogon.PS1 2019-05-29 theitguys theitguys [00796e] setting up new repo
 Set-LoginsRegistry.ps1 2020-11-08 BogusException BogusException [c223f0] New stuff
 Set-RegShowLogins.ps1 2020-11-08 BogusException BogusException [c223f0] New stuff
 Start-Cleanup.PS1 2019-05-29 theitguys theitguys [00796e] setting up new repo
 Test-Pending-Reboot.PS1 2019-05-29 theitguys theitguys [00796e] setting up new repo
 Test-PendingReboot.txt 2019-05-29 theitguys theitguys [00796e] setting up new repo
 msiserverInSafeMode.txt 2019-05-29 theitguys theitguys [00796e] setting up new repo

Read Me

#
# Start-Cleanup.PS1 - by David Yoder
#
# initial commit 7:56 PM, 1/9/2019
#
Ok everyone. Since the script I posted earlier received good feedback, here's one that I've been working on this week. I'll probably need to go over it once more to make sure everything is in tip-top shape, but it's functional right now. It's long and will probably require you read through the comment based help I put at the top, but essentially it automates cleanmgr.exe in Windows. I pulled the settings from Windows 7, 8.1, and 10 so it should definitely run on at least those operating systems.

To have cleanmgr.exe clean the computer using the settings in the script just run the script with a parameter indicating the category you want to clean. These can be -User, -System, -WindowsUpdate, -WindowsPreviousVersions, -Invasive, -Misc, or -All. You can specify any combination of categories to clean, but you'll need to use at least 1. I haven't gone through and created parameter sets yet, so for now there's no PowerShell imposed requirement for command line arguments - just know that you'll need to use at least 1 of those categories.

I was trying to think of ways to make free space on an endpoint, and right now in Ninja it's just so overly complicated and usually requires remoting in. And Ninja's out-of-the-box settings are lacking so very much.
The target use case for this script is to set it as an automatic action in a policy condition. But another use case would be to run it at regular intervals but with the -NoCleaning switch. This will only write the settings to the Windows Registry. Then you can setup a custom action in the tray icon to run cleanmgr.exe /sagerun:<value-from-script>, or I guess you could just have it run this script again with the category (or categories) to be cleaned.
The script needs to be run as System to write the changes to the registry. But once you do that you can run it as the currently logged in user if that suites your needs.
One of the major problems I have with this script is determining what is actually cleaned. I tried to search through Microsoft's documentation, but couldn't find exactly how cleanmgr.exe works. So I don't know if running cleanmgr.exe as System produces different results than when running it as a regular user, or a regular user with an administrative token. So that part is still up in the air.

~David Yoder

Join us on slack here:

https://join.slack.com/t/ninjarmm-colab/shared_invite/enQtNDczNDQxMTE1MTM3LWY3ZjYwMTFhYzE0NjE3M2YzMDkxNGNhOTVjNzFkMjk1MGZmZjQzM2RiN2JjYWE2ZjVmNjg4MTQ3ZTJmMzVlODU
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.