Hi guys,
I'm a french girl, and a newbie into scripting domain, so if I just don't understand some of the things you explain me, please just be cool :)
So, I want to execute a remote powershell script from a windows 2003 server (monitoring server) which will be able to count mailboxes on my unique exchange server.
I try this which is working well on the exchange server, but it returns an error message on my remote server :
"Le terme « Get-MailboxStatistics » n'est pas reconnu comme nom d'applet de commande, fonction, fichier de script ou pro
gramme exécutable. Vérifiez l'orthographe du nom, ou si un chemin d'accès existe, vérifiez que le chemin d'accès est co
rrect et réessayez.
+ CategoryInfo : ObjectNotFound: (Get-MailboxStatistics:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Here is the script (get on ne the web) :
param([string] $Param )
$Results = @()
$CountMB = 0
if(!$param)
{
$Servers = Get-Process -computerName name_of_server| Get-ExchangeServer | Where {$_.ServerRole -eq "Mailbox"} | Sort Name
Foreach($Server in $Servers)
{
$dbs = Get-MailboxDatabase -server $Server | Sort Name
foreach($db in $dbs)
{
$mb = Get-MailboxStatistics -Database $db | Where {$_.DisconnectDate -eq $null -and $_.ObjectClass -eq 'Mailbox'} | Measure-Object
$mbdis = Get-MailboxStatistics -Database $db | Where {$_.DisconnectDate -ne $null -and $_.ObjectClass -eq 'Mailbox'} | Measure-Object
Write-Host "$($Server) `t $($db.name)`t $($a.count)"
$Obj = New-Object PSObject
$Obj | Add-Member NoteProperty -Name "Server" -Value $Server
$Obj | Add-Member NoteProperty -Name "Database" -Value $db.Name
$Obj | Add-Member NoteProperty -Name "Mailboxes" -Value $mb.count
$Obj | Add-Member NoteProperty -Name "Disconnected Mailboxes" -Value $mbdis.count
$Results += $Obj
}
}
}
else
{
$server = $param
$dbs = Get-MailboxDatabase -server $Server | Sort Name
foreach($db in $dbs)
{
$mb = Get-MailboxStatistics -Database $db | Where {$_.DisconnectDate -eq $null -and $_.ObjectClass -eq 'Mailbox'} | Measure-Object
$mbdis = Get-MailboxStatistics -Database $db | Where {$_.DisconnectDate -ne $null -and $_.ObjectClass -eq 'Mailbox'} | Measure-Object
$Obj = New-Object PSObject
$Obj | Add-Member NoteProperty -Name "Server" -Value $Server
$Obj | Add-Member NoteProperty -Name "Database" -Value $db.Name
$Obj | Add-Member NoteProperty -Name "Mailboxes" -Value $mb.count
$Obj | Add-Member NoteProperty -Name "Disconnected Mailboxes" -Value $mbdis.count
$Results += $Obj
$countmb += $mb.count
}
Write-Host
Write-Host "$($Server) has a total of $($CountMB) mailboxes" -ForegroundColor Green
}
$Results | FT -AutoSize
Any help will be appreciated !
Thanks all