Powershell – Get SAM name

Gets the SAM name of users in a specific OU and then displays them as swhiting, jdoe, ldoe

etc, this was so I could then put them in another script.

(Get-ADUser -SearchBase "OU=FinanceTeams,OU=CustomerServices,OU=Operations,OU=.Users,OU=stevenwhiting,DC=stevenwhiting,DC=co,DC=uk" -Filter {Enabled -eq $true} |  Select-Object -ExpandProperty SamAccountName | ForEach-Object { "'$_'" }) -join ','