When I run the following script it returns: @{Name=<Usersname>} not found
Foreach ($object in Get-childitem "\\HomeDriveServer\home$\" | select Name)
{
$userAccount = get-aduser -Filter {SamAccountName -like "*$object*"}
if($userAccount -eq $null)
{
write-host "$object not found"
}
else
{
write-host "$object found"
}
}
Get-childitem "\\HomeDriveServer\home$\" | select Name returns the list of folder names fine without the @{Name=XXX}
why is the @{Name=XXX} appearing, and how can I get rid of it?
Thanks
What you see is not exactly what you get. Your query returns a collection.
You should try :