Count Users in AD By OU

I am trying to use the script form the site posted by Jeff Hicks and below and I repeatedly get the error in Powershell:–>
Get–ADUser : The term ‘Get–ADUser’ 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 correct and try again.
I am on a Server 2012R2 with AD module loaded. Do I have a version issue? I had to modify “Property to Properties” to make the first part work. What up??
Get-ADOrganizationalUnit -Filter * -Properties DistinguishedName|
foreach {
$users= Get–ADUser –filter * –searchbase $.DistinguishedName –ResultPageSize 2000 –resultSetSize 500 –searchscope Onelevel
$total=($users | measure-object).count
$Enabled=($users | where {$
.Enabled} | Measure-Object).count
New-Object psobject -Property @{

It looks like you have some bad characters from a copy/paste. Specifically the “-” in your get-aduser is a bit too long. I copied and pasted into my ISE and got the same error. Try typing it in manually and see if that gets it to run for you.

I don’t know. I got the same error as you did. I deleted Get-ADUser out of the script and then retyped it. Worked fine after that. I suspect its an artefact of copying the script

You got it. It was the “hyphen” between the get-aduser. All works correctly now. Thanks for the help.