Skip to content

Instantly share code, notes, and snippets.

@OCram85
Last active January 10, 2019 13:33
Show Gist options
  • Save OCram85/4ddb27ca34c7b5cc2e1a3363ea0eb463 to your computer and use it in GitHub Desktop.
Save OCram85/4ddb27ca34c7b5cc2e1a3363ea0eb463 to your computer and use it in GitHub Desktop.
Get-AllADGroups.ps1
function Get-AllADGoups {
<#
.SYNOPSIS
A brief description of the function or script.
.DESCRIPTION
Describe the function of the script using a single sentence or more.
.PARAMETER One
Description of the Parameter (what it does)
.INPUTS
Describe the script input parameters (if any), otherwise it may also list the word "[None]".
.OUTPUTS
Describe the script output parameters (if any), otherwise it may also list the word "[None]".
.EXAMPLE
.\Remove-Some-Script.ps1 -One content
.NOTES
File Name : Get-AllADGoups.ps1
Author : fullname - mail
Requires : ModuleNames
.LINK
Static link to Project
#>
[CmdletBinding()]
[OutputType('myTypeName')]
param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[ValidateNotNullOrEmpty()]
[string[]]$Identity,
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$Server = 'my.domain.com'
)
begin {
Import-Module -Name ActiveDirectory -ErrorAction Stop
}
process {
foreach ($Ident in $Identity) {
$Groups = Get-ADPrincipalGroupMembership -Identity $Ident -Server $Server | Select-Object -ExpandProperty 'Name'
foreach ($Group in $Groups) {
[PSCustomObject]@{
PSTypeName = 'myTypeName'
Identity = $Ident
GroupDetails = Get-ADGroup -Identity $Group -Server $Server -Properties *
}
}
}
}
end {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment