This is a collection of PowerShell commands for working with Active Directory groups. These commands can be used to retrieve information about groups, filter groups based on certain criteria, and perform other tasks. The commands are written in PowerShell, a scripting language commonly used for automating administrative tasks in Windows environments.
Here's a breakdown of the commands used in the README:
-
whoami
- A built-in Windows command
- Displays information about the current user
- Parameter /groups: Shows group membership information
- Parameter /FO CSV: Formats the output as CSV (Comma-Separated Values)
-
ConvertFrom-Csv
- A PowerShell cmdlet
- Converts CSV strings into custom objects
-
?{ }
- PowerShell alias for Where-Object
- Filters objects based on specified criteria
-
-like
- PowerShell comparison operator
- Performs wildcard string matching
-
Group-Object
- PowerShell cmdlet
- Groups objects based on a specified property
- Parameter -NoElement: Omits the group members from the output
-
%{ }
- PowerShell alias for ForEach-Object
- Performs an operation on each item in a collection
-
Sort-Object
- PowerShell cmdlet
- Sorts objects based on specified properties
- Parameter -Descending: Sorts in descending order
-
Select-Object
- PowerShell cmdlet
- Selects specified properties of objects
- Parameter -First: Selects the first n number of objects
-
|
- PowerShell pipeline operator
- Passes the output of one command as input to the next command
These commands are combined to retrieve group information, filter results, perform string operations, group and sort data, and select specific output, allowing for various manipulations of Active Directory group data.
Please note that the column name Gruppenname
used in these examples is based on a German language Windows system. You may need to change this to match the language of your Windows system. To determine the correct column name for your system, run the following command and check the output:
whoami /groups /FO CSV | ConvertFrom-Csv | Get-Member -MemberType NoteProperty
whoami /groups /FO CSV | ConvertFrom-Csv
whoami /groups /FO CSV | ConvertFrom-Csv | ?{$_.Gruppenname -like "*RDP*"}
whoami /groups /FO CSV | ConvertFrom-Csv | Group-Object Typ -NoElement
whoami /groups /FO CSV | ConvertFrom-Csv | %{$_.Gruppenname} | ?{$_ -like "*\*"} | %{$_.Split("\")[1].Split("_")} | Group-Object -NoElement | Sort-Object Count -Descending | Select-Object -First 25