Public/Get-EnumeratedADUser.ps1
Function Get-EnumeratedADUser { <# .SYNOPSIS Get EnumeratedADUser .DESCRIPTION Get EnumeratedADUser .PARAMETER User The user .PARAMETER Key The property name .PARAMETER Value The value of the property .EXAMPLE Get-EnumeratedADUser .INPUTS System.String .LINK about_functions_advanced .LINK about_CommonParameters #> [CmdletBinding(DefaultParameterSetName = 'Key')] [OutputType('System.Object')] Param ( [Parameter( Mandatory = $True )] [ArgumentCompleter( { (Get-ADUser -Filter *).Name })] [String]$User, [Parameter( ParameterSetName = 'Key' )] [String]$Key = "*", [Parameter( ParameterSetName = 'Value' )] [String]$Value ) Begin { [Array]$ADUserInfo = $((Get-ADUser -identity $User -properties *).GetEnumerator()) } Process { If ($Key) { $Result = $ADUserInfo | Where-Object { $_.Key -like "*$Key*" } } If ($Value) { $Result = $ADUserInfo | Where-Object { $_.Value -like "*$Value*" } } } End { Write-Output $Result } } |