Skip to content

Instantly share code, notes, and snippets.

@josephkern
Last active July 20, 2017 16:17
Show Gist options
  • Save josephkern/58e1bc43202632a9488672d343a58162 to your computer and use it in GitHub Desktop.
Save josephkern/58e1bc43202632a9488672d343a58162 to your computer and use it in GitHub Desktop.
Recursively enumerate nested groups in AD
function getgroups ($object) {
### Example: getgroups -object somename.lastname | select name -unique
Get-ADPrincipalGroupMembership $object | Foreach {
$_
Get-ADPrincipalGroupMembership $_
}
}
function GetPortsandPrinters {
$printers = Get-Printer
foreach ($port in $(Get-PrinterPort)) {
$printers | ? { $_.PortName -like $port.Name } | select Name,
@{Name = 'Port Name'; Expression = {$port.Name}},
@{Name = 'Host Address'; Expression = {$port.PrinterHostAddress}}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment