Functions/Public/Start-COVUserSecGroups.ps1
<#
.SYNOPSIS Retrieves all security groups the AD user is a member of. .NOTES The -User parameter is mandatory and the only parameter needed. .LINK Specify a URI to a help page, this will show when Get-Help -Online is used. .EXAMPLE Start-COVUserSecGroups -User Retrieves all security groups the AD user is a member of. #> function Start-COVUserSecGroups { [CmdletBinding()] param ( # Parameter help description [Parameter(Mandatory)] [string] $User ) try { $Adgroups = Get-ADPrincipalGroupMembership $User | select name | Sort-Object -Property @{Expression = "name"; Descending = $false} $Adgroups | Out-GridView } catch { $ErrorM = $_ if ($ErrorM.Exception -like "*cannot find *") { Write-Host "Hey Dumbo, You spelled the name wrong" } } } |