I tried your script, and it does return results, but does error on the following:

This is the code Im using:

The term 'sAMAccountName' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is cor
rect and try again.
At D:\temp\scripts\getusers.ps1:11 char:15
+ sAMAccountName <<<< ,givenName,sn
+ CategoryInfo : ObjectNotFound: (sAMAccountName:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Enterprise Administrators
The term 'sAMAccountName' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is cor
rect and try again.
At D:\temp\scripts\getusers.ps1:16 char:15
+ sAMAccountName <<<< ,givenName,sn
+ CategoryInfo : ObjectNotFound: (sAMAccountName:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Schema Administrators
The term 'sAMAccountName' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is cor
rect and try again.
At D:\temp\scripts\getusers.ps1:21 char:15
+ sAMAccountName <<<< ,givenName,sn
+ CategoryInfo : ObjectNotFound: (sAMAccountName:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

Featured Post

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.