Export all the users from an Active Directory server to CSV

Your script is working fine for me and is working like expected. Though your current output is a table rather than CSV. You could look into Export-Csv for that.

What might be/is missing if it tells you that it's an unknown command is the actual module. In order to have the ActiveDirectory module available you will have to have the RSAT (Remote Server Administration Tools) installed for AD. They're available as a separate download for Windows 7 and/or might be available as an OS Feature.

You can check which modules are available by running Get-Module -ListAvailable and to see which are currently loaded you can run Get-Module. If you want to load a module (like the ActiveDirectory module) you can use Import-Module.

In your case it should look like this:

Import-Module ActiveDirectory
Get-ADUser -Filter {Enabled -eq "True"} | Select-Object SamAccountName,Name,Surname,GivenName | Export-Csv -Path C:\Temp\Export.csv -NoTypeInformation