As a way to kick off migration from Reddit to Lemmy, let’s start with a classic thread. So, what have you done with PowerShell this month?
For bonus imaginary points, have you done anything in regards to the Great Reddit Migration?
I saved a LOT of time by being able to set a new printer as the fefault for dozens of endpoints. Nothing crazy, but it was a nice feeling
Did an inventory of departments in our Active Directory domain and found too damned many to have them be at all meaningful.
If you want to segment e.g. retail store employees, it helps if they aren’t in a department consisting of one store in Auckland, or Runcorn or wherever.
I wrote a little wordle chat bot that aggregates and comments on my friends’ groupme chat. So in the evening it notifies anyone in the chat that hasn’t done the wordle that day, and if everyone’s done it outputs a summary of how we did as a group.
So… I’m not a powershell expert by any means, I fell into a powershell hole about 3 weeks ago when I realized a lot of my time was spent logging into different tenants to make tiny changes. I know some of my team is afraid of powershell, it’s not super friendly without a little practice, then tracking down saved scripts, etc, for things you only do once.
So I set out with a plan to make a menu where staff can just pick what they want, login to the tenant, and make changes within seconds compared to 10-15 minutes.
Here is a screenshot of my menu - https://i.imgur.com/Me69i5z.png
Today’s task was creating a small form for changing Out of Office replies to 4 email accounts that change for nearly every holiday, so I have to spend 15 minutes logging into each email, changing the dates and message. I made a script, it’s the one marked out since it has some PII in the name. Anyway, it asks for the start date, end date, and the message, then within 10 seconds all accounts are updated and ready to go. Set it and forget it.
My code is a mess, but it works. Files are shared in Sharepoint and a profile is setup to grab any updated files when you first launch powershell and copy them to your local Documents/Powershell directory. Modules, external scripts, etc, updated on the fly until it gets too large of course.
Anyway, that’s my project, save time doing the same shit over and over in a user friendly console window, with documentation and the ability for any team member to use with little effort. Needed to toot my horn a little today, been watching videos and testing my codes for last 3 weeks.
Wrote a C# powershell module with two commands, one for retrieving tags/keyword metadata from passed in imagefiles, and one for creating windows shortcuts from passed files.
Import-Module .\PSGetTagMetadata.dll # Find all jpg and png images with just one tag, and create a shortcut to them. $myfiles = gci -Path "C:\users\username\Pictures\" -Recurse -Include "*.jpg","*.png" | Get-TagMetadata | ? { $_.Keywords.Count -eq 1 } $myfiles | % { $_.File } | Set-Shortcut
It can still be improved upon, of course, but for the moment it did what I needed.
Made a Powershell script/app/gui for our T2 team to use to reset local admin passwords on apple/Jamf devices.
Packaged up an in-place win10 to win11 upgrade with PSADT that uses deferrals, user interaction, and deadlines. It started simple, but it has turned into a behemoth of a script that does things like check for last reboot time, and if the device hasn’t rebooted in the last 48 hours, swap the PSADT XML on the fly to show a different reboot message and make a scheduled task to kick off the install after a reboot (which actually required the task calling a script that did a start-sleep for about 2 minutes before calling the actual installation script because it needed to wait for certain other tasks to complete or it would just fail). It also keeps track of failures and gives up after 5 attempts so the user isn’t hit with post-install reboots every day. It also flips back and fourth between using setup.exe from the image and Windows11InstallationAssistant.exe between each failure because some machines respond better to different installation types. It also does a cleanup with cleanmgr before kicking off because that was a problem for some devices. It’s been a Rollercoaster. Once I have it all sorted out I am going to have to post it somewhere so that other people don’t have to go through the same trouble that I did.
Oh also like writing scripts to compare CSV files to find matches and stuff… You know. The usual.