I use this one once in awhile when I have a user or service account that is getting locked our repeatedly, and I need to see where its coming from. You should be able to run this from your local computer. It will used the entered credentials to remote into the domain controllers and pull […]
Pin to Quick Access with Powershell
So here’s a fun one that saved me buckets of time the other day. We needed to give our not so tech savvy users easy access to a folder without having to provide directions to them to navigate to the folder. Now, just like with everything else, there were multiple ways to tackle this problem, […]
Save Credentials to a File
We’ve all been guilty of it once in awhile. You know what I’m talking about. Saving plain text credentials into a script. It’s great for testing in certain situations. I’ve even been guilty of saving a script and keeping it for awhile on my laptop with the credentials in plain text. It’s just to convenient […]
Module Highlight: Invoke-CommandAs
Invoke-Command is a great tool in the powershell arsenal, but what if you need a little more than what the standard Invoke-Command has to offer? For example, I have a funky batch script that does some SQL juju that needs to be run as the SYSTEM user on demand. Or, what if I’m running into […]
One-Liner: Move Computer to new OU
Periodically, I scan our Active Directory (AD) for machines that haven’t contacted AD in 60+ days. So one thing I like to do is stage them in an OU called “Obsolete”, and then wait another 60+ days to remove them from AD. Our turnover is generally not to high, but it’s enough that moving/removing the […]
One-Liner: Test-NetConnection Tweaked
Test-Connection is a great tool, but sometimes I would like to ping a list of IPs periodically. Here’s a little one-liner that will do exactly that: Just point it to a text file formatted like so: And here’s the output: Enjoy!
One-Liner: Get O365 User Licenses
Here’s a great one liner I use all the time to run a report get our user’s O365 licenses. This should go without saying, but make sure you’ve installed the MSOnline module. Then connect with Connect-MSOLService. You should get an output similar to this: You could add a Export-Csv or Convertto-JSON | Out-file .\filename.json if […]
Press any key to continue……powershell style.
Such a simple thing really, but so handy if you want to pause somewhere in a script to read some sort of output before continuing. One of the most common ways to pause a script is to use the Read-Host command like this: 1 Read-Host -Prompt "Press enter to continue"Read-Host -Prompt "Press enter to continue" […]
Errors? What errors? Oh…..that $error.
We all hate it when your script throws an error. I mean they’re great when you’re writing the script. They help you figure out what’s wrong, but what if you need to keep a log of any errors after you’ve deployed the script? Recently, I was putting a script together to a script to alert […]
Download files with Powershell and Invoke-WebRequest
While there are quite a few ways to download files with powershell, my usual go to if I’m limited to strictly powershell is Invoke-WebRequest. Here’s an example: 1 Invoke-WebRequest https://urltofile.com/file -OutFile "C:\pathtofile.bleh"Invoke-WebRequest https://urltofile.com/file -OutFile "C:\pathtofile.bleh" While not as elegant as say wget or curl, it does the trick when there are no other options besides […]