Here is the following PowerShell command I am trying to run but keep getting errors and I am not sure what is missing
$sAMAccountName=Import-csv -path Z:\PowerShellScripts\Input\username.csv | get-aduser -Identity {$sAMAccountName} -Properties LastlogonDate,Enable
The Goal is to find the LastlogonDate and Enabled Status of a list of users I was supplied by an application owner
The .csv file is formatted:
sAMAccountName
stmAdairB
mhhAdamsM
tmcAllenK
tmcAllisH
dhlaltger
mmcAlvarM
Here is the error I receive in PowerShell:
Get-ADUser : Cannot evaluate parameter 'Identity' because its argument input did not produce any output.
At line:1 char:97
+ ... user -Identity {$sAMAccountName} -Properties LastlogonDate,Enabled
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (@{sAMAccountName=wrigc}:PSObject) [Get-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : ScriptBlockArgumentNoOutput,Microsoft.ActiveDirectory.Management.Commands.GetADUser
Any help would be greatly appreciated just haven't had any luck finding the info I need through searches
Roland Robinson Roland.Robinson@highpoint-solutions.com