Category: PowerShell

  • Powershell: A script to find all members of several groups refined

    One of the scripts that I use most often is the one I wrote about back in September of 2019. Usually, I only run it for up to ten or so groups, so it’s not a big problem to simply swap out the group name, rince and repeat. Recently, however, I needed to run it […]

  • Powershell: Add user to multiple groups

    A while back, I had a user that had to be added to a large number (150+) of active directory groups. Rather than doing so manually, I spent a little time looking up how to automate it, and created a script to help me do it. Here’s how I constructed it:

  • PowerShell: Find all groups containing a specific string

    Sometimes, you need a list of all groups whose name contain a specific string, whether that is in the beginning, middle, or end of the group name. As we’ve seen previously, looking up groups in PowerShell is done with the Get-ADGroup command. Adding the -filter parameter allows us to find groups that satisfy our needs. […]

  • PowerShell: Check Remote Computer Disk Capacity

    From time to time, I get tickets where one of many possible root causes may be a full disk. While accessing this information over RDP is often an option, it is rather more intrusive than needed. What’s more, I usually don’t have access to access file servers over RDP. Enter PowerShell and the get-WmiObject query!

  • PowerShell: Check computer last logon date

    In a recently closed ticket, I had specified that the solution would be automatically applied upon reboot of a computer. As so often happens one of the twenty or so users affected by the solution emailed to say that it didn’t work. Having dealt with said user before, I had a hunch that they hadn’t […]

  • PowerShell: Pipe output to CSV file

    Last week, I showed you how to get specific properties for all users in a given OU. Knowing that the output of that query quickly gets hard to navigate, wanting to remove the extraneous data that the customer didn’t request, and assuming that they wanted to manipulate the data, I decided to return the results […]

  • PowerShell: Getting properties for all user objects in a given OU

    Two weeks ago, I showed you how I got some specific properties for a specific user. Perhaps unsurprisingly, the next request from my customer was a similar dump from a specific OU. While the Identity parameter works well when you’re dealing with a specific user, it doesn’t help when you want all users.

  • Powershell: Retrieving all properties for a given user object

    I was asked to provide an overview of all available properties in an Active Directory user object for an upcoming project. As it turns out, that is very easily accomplished. Unsurprisingly, PowerShell has an applet for this. We use the Get-ADUser applet, with the parameters Identity to identify the user in question and Properties with […]

  • PowerShell: Look up all direct reports

    In the Organisation tab of a user object in Active Directory, you have the option to set who is the manager of a given user. While this may seem unnecessary, I have found it very useful when supporting a customer where I don’t know the reporting lines, as it gives me a one-stop place to […]

  • PowerShell: Count enabled user accounts

    A few weeks ago, I showed you how to get a list of all enabled user accounts in PowerShell. Perhaps unsurprisingly, after having presented this to my customer, it transpired that what they really wanted, was to know how many enabled user accounts existed in Active Directory.

  • PowerShell: Find all users in a specific OU

    One of my customers asked for an overview of the UPNs of all users in a specific OU. Having become fairly familiar with the Get-ADUser command, I decided to see if I couldn’t make it do this, too.