In order to run Exchange Server commands within a Powershell script, the relevant cmdlets need to be 'called' within Powershell.
This is accomplished with the following line, which is found at the start of nearly all of my Powershell scripts.
#Enable Exchange cmdlets
add-pssnapin *exchange* -erroraction SilentlyContinue
If you attempt to run Exchange commands in Powershell (eg. Get-Mailbox) without loading the Exchange cmdlets first, you will get an error similar to the following;
The term 'get-mailbox' 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.
At line:1 char:12
+ get-mailbox <<<<
+ CategoryInfo : ObjectNotFound: (get-mailbox:String) , CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException