Hi - I'm attempting to write a function with 2 overloads that will allow me to perform a get-qaduser on a specific user and return a specific attribute.
Now, I can use overloads normally IE - on a sql query, or just to write the overloads to console... But, trying to use them with get-qaduser is another thing. I am able to use one overload to query ad for the user, or for the attribute, but not both.
Can anyone offer any help? Below is the simple function and the error returned, and an example of one overload.
Thanks in advance
Rob.
function adUserSpecific ($userName , $attrib) {
Get-QADuser $userName -DontUseDefaultIncludedProperties -IncludedProperties $attrib | select $attrib
}
adUserSpecific ('user123' , 'userprincipalname' )
Get-QADUser : Cannot validate argument on parameter 'IncludedProperties'. The argument is null or empty.
Supply an argument that is not null or empty and then try the command again.
At line:5 char:78
+ Get-QADuser $userName -DontUseDefaultIncludedProperties -IncludedProperties <<<< $attrib | select $
attrib
+ CategoryInfo : InvalidData: (:) [Get-QADUser], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Quest.ActiveRoles.ArsPowerShellSnapIn.Po
wershell.Cmdlets.GetUserCmdlet
================================= Example of overload working.
function adUserSpecific ( $attrib) {
Get-QADuser ca-rdixon -DontUseDefaultIncludedProperties -IncludedProperties $attrib | select $attrib
}
adUserSpecific ( 'userprincipalname' )
UserPrincipalName
-----------------
user123@myDomain.net