Sunday, September 6, 2015

[EX2010] Common cmdlets




    • Configure contact picture in Exchange 2010:

    Import-RecipientDataProperty -Identity MMM -Picture -FileData ([Byte[]]$(Get-Content -path "c:\.jpg" -Encoding Byte -ReadCount 0))

    • Check Exchange Rollup Version

    Get-Command Exsetup.exe | ForEach-Object {$_.FileVersionInfo}

    • List all Disconnected Exchange 2010 Mailboxes

    Get-MailboxDatabase | Get-MailboxStatistics | where {$_.DisconnectReason -ne $null} | ft displayname,database,disconnectreason -auto

    • Enable execution of Powershell scripts

    set-executionpolicy remotesigned

    • Get mailbox copy status information

    Get-MailboxDatabaseCopyStatus -Identity “Mailbox Database Name” | select DatabaseName,Status,ActiveDatabaseCopy,ContentIndexState

    • Import PST Files
    Get-Mailbox -Database “Mailbox Database Name”| Import-Mailbox -PSTFolderPath “Path import pst file location”

    • Show all Mailboxes which are bigger than 400 mb and sorted
    Get-MailboxStatistics -server “Mailbox Server Name”| Where-object {$_.TotalItemSize -gt 400mb} | Sort-Object TotalItemSize -Descending | ft DisplayName,@{label=”TotalItemSize (MB)”;expression={$_.TotalItemSize.Value.ToMB()}},ItemCount > "C:\Outputfile.txt"

    • Verify if the database is mounted on the server with preference 1 (with colors)}”
    Get-MailboxDatabase | Sort Name | ForEach {$db=$_.Name; $xNow=$_.Server.Name ;$dbown=$_.ActivationPreference| Where {$_.Value -eq 1};  Write-Host $db “on” $xNow “Should be on” $dbOwn.Key -NoNewLine; If ( $xNow -ne $dbOwn.Key){Write-host ” WRONG” -ForegroundColor Red; } Else {Write-Host ” OK” -ForegroundColor Green}}