Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Trying to retrieve AD Object properties using the Get-ADuser cmdlet with piped input in the -Identity Parameter

$
0
0

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


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>