I am working on a PowerShell script to get all the users from an specific defined OU and add them to the following array.
$adusernames = Get-ADUser -filter * -SearchBase "OU=TestUsers,DC=xyz,DC=com" | Select sAMAccountName
Issue im running into, is when the Get-ADuser command gets the users, it adds the users in the array with the sAMAccountName attribute.
Basically, this array is getting fed into a loop, where each element is being sent to the following query 1 by 1 to list out that users mail attribute:
$mailAttribute = (Get-ADUser $Name -properties mail).mail
For the $Name variable, powershell is feeding it the following value: sAMAccountName=username
Is there a way to just add the sAMAccountNames return value as a string value into the array?
$adusernames = Get-ADUser -filter * -SearchBase "OU=TestUsers,DC=xyz,DC=com" | Select sAMAccountName
Issue im running into, is when the Get-ADuser command gets the users, it adds the users in the array with the sAMAccountName attribute.
Basically, this array is getting fed into a loop, where each element is being sent to the following query 1 by 1 to list out that users mail attribute:
$mailAttribute = (Get-ADUser $Name -properties mail).mail
For the $Name variable, powershell is feeding it the following value: sAMAccountName=username
Is there a way to just add the sAMAccountNames return value as a string value into the array?