When i run this powershell command i get an error “the term get-mailboxstatistics is not recognized” why is that?

Set the Exchange server to run the query against

$ExchangeServer = “xxxx"

Run the query

$Top300Users = Get-MailboxStatistics -server $ExchangeServer |sort-object -Property totalitemsize -des |select-object Displayname, ItemCount, @{name=’Total Item Size (MB)’;expression={$_.totalitemsize/1MB}} -first 300 |Convertto-html

Set the mail message properties

$FromAddress = “xxxx”
$ToAddress = “xxxx”
$MessageSubject = “Weekly report: Biggest mailboxes on Exchange server ” + $ExchangeServer
$SMTPServer = “xxxx”

Create the mail message

$SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress, $ToAddress, $MessageSubject, $Top300Users
$SMTPMessage.IsBodyHtml = $true

Send the message

$SMTPClient = New-Object System.Net.Mail.SMTPClient $SMTPServer
$SMTPClient.Send($SMTPMessage)

1 Spice up

Are you using regular powershell on the server or the exchange management shell? The EMS has a bunch of extra profile items and such that get loaded in specific to exchange.

3 Spice ups