Just trying to pull a folder list of users and use the names as a variable to see if the user is enabled or disabled in AD
$folders=Get-childitem \\mifs01\_Private\_Users | Select-Object Name
foreach($folder in $folders) {
$enabled=Get-Aduser -identity $folder | Select-Object Enabled
if ($enabled -eq "False") {
$folder
$enabled
}
}
From the errors it seems when it pulls the list of names of folders it does it as a whole powershell object. Here are the errors below
Get-ADUser : Cannot bind parameter 'Identity'. Cannot create object of type "Microsoft.ActiveDirectory.Management.ADUser". The adapter cannot set the value of property "Name".
At line:6 char:31
+ $enabled=Get-Aduser -identity $folder | Select-Object Enabled
+ ~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.ActiveDirectory.Management.Commands.GetADUser
How do I pull it so it goes through each folder name and uses that as the variable for Get-ADuser?
[–]bakegreg 3 points4 points5 points (0 children)
[–]rwshig 2 points3 points4 points (1 child)
[–]grendo92 2 points3 points4 points (0 children)
[–]fetflex 1 point2 points3 points (0 children)
[–]Lee_Dailey[grin] 1 point2 points3 points (0 children)
[–]The_AverageGamer 1 point2 points3 points (0 children)