Guys.
I have this script that been put together in a few different ways but i think i have something that is going to work. The script will connect to each AD accounts it finds in an OU, then match Attribute1 and then switch.
The issue that im having is that i cant get it to pick up the user name form the command below. Just using $_ works but it displays Domain\Username where reallyu i just want the SamAccountName.
I have been banging my head and trying different things but cant quite get it to work. Any ideas?
write-host $profilepath\$_.SamAccountName
----
The script is below
-----------------------------
Connect-QADService -Service "SERVER-NAME -Proxy$OUSelected = "OU-NAME"
Get-QADUser -SizeLimit 0 -IncludedProperties "Attribute1" -SearchRoot $OUSelected |
ForEach-Object{
$siteid = switch ($_."Attribute1") {
'CH' { $ProfilePath = "\\PATH1"}
'EU' { $ProfilePath = "\\PATH2"}
'HK' { $ProfilePath = "\\PATH3"}
'US' { $ProfilePath = "\\PATH4"}
default { 'No site' }
}
write-host $profilepath\$_.SamAccountName
}