Forum Discussion
foreach and out-file- no data
Assuming you are piping in the SamAcountName.
Try Get -ADUser -identity $_.$User
yes, the file contains SamAccountNames
I tried the -identity para but received the error below
Get-ADUser : Cannot validate argument on parameter 'Identity'. The argument is null. Provide a valid value for the argument, and
then try running the command again.
At line:4 char:26
+ if (Get-ADUser -identity ($_.$User) -Properties displayname,mail,dist ...
+ ~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-ADUser], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.ActiveDirectory.Management.Commands.GetADUser
Get-ADUser : Cannot validate argument on parameter 'Identity'. The argument is null. Provide a valid value for the argument, and
then try running the command again.
At line:4 char:26
+ if (Get-ADUser -identity ($_.$User) -Properties displayname,mail,dist ...
+ ~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-ADUser], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.ActiveDirectory.Management.Commands.GetADUser