Some Exchange 2007 CMDlets
Mailbox Size Report - Individual Database
cls
Get-MailboxStatistics -Database "ecgcmail01\webmail users\mailboxes" | Sort-Object TotalItemsize -Descending | Where {$_.TotalItemSize -gt 145MB} | ft Displayname , @{expression={$_.TotalItemSize.Value.ToMB()}}, StorageLimitStatus
Get-MailboxStatistics -Database "ecgcmail01\general users\mailboxes" | Sort-Object TotalItemsize -Descending | Where {$_.TotalItemSize -gt 65MB} | ft Displayname , @{expression={$_.TotalItemSize.Value.ToMB()}}, StorageLimitStatus
*******************************
update 10K Photo in AD
Import-RecipientDataProperty -Identity "Bharat Suneja" -Picture -FileData ([Byte[]]$(Get-Content -Path "C:\pictures\BharatSuneja.jpg" -Encoding Byte -ReadCount 0))
**************************************
Enable OWA for list of users
$path = "d:\Andy\Owa.txt"
foreach ($line in Get-Content $path) { Set-CASMailbox –Identity $line –OWAEnabled:$true }
**********************************************
Logon Statastics Report
Get-LogonStatistics -Server "ecgcmail01" | Sort-Object Logontime –Descending | ft userName , Logontime
*******************************
List of Databases
Get-Mailbox -Database "ecgcmail01\general users\mailboxes" |Sort-Object Name –Descending
*******************************
Move all Mailboxes from database
Get-Mailbox -Database "ecgcmail01\ecgc users\general user" |Move-Mailbox -TargetDatabase "ecgcmail01\general users\mailboxes" -PreserveMailboxSizeLimit
*******************************
List Group Members
Get-QADGroupMember -Identity ITCoordinators
*******************************
For Logon Details
$last30d = (Get-Date).Subtract((New-TimeSpan -Days 15))
get-mailboxstatistics -Server ecgcmail01 | where {$_.lastlogontime -lt $last30d} | Ft Displayname , lastlogontime
*******************************
Add User to Group
Add-QADMemberOf -Group "Internet users" -Identity "ecgcindia\sukhan.singh"
*******************************
Get all disconnected mailboxes
Get-MailboxStatistics | where-object { $_.DisconnectDate -ne $null } | Select DisplayName,MailboxGuid
*******************************
Remove a single disconnected mailbox
Remove-Mailbox -Database <Database-Name> -StoreMailboxIdentity <MailboxGuid> -confirm:$false
*******************************
Remove all disconnected mailboxes
$users = Get-MailboxStatistics | where-object { $_.DisconnectDate -ne $null } | Select DisplayName,MailboxGuid,Database
*******************************
Update GAL
Update-GlobalAddressList -identity "Default Global Address List"
*******************************
Certificate Request
New-ExchangeCertificate -GenerateRequest -Path c:\webmail_ecgc_in.csr -KeySize 1024 -SubjectName "c=IN, s=Maharashtra, l=Mumbai, o=Export Credit Guarantee Corporation of India, ou=MAIL SERVER, cn=webmail.ecgc.in" -DomainName ecgcindia.com, ecgcowa01.ecgcindia.com, ecgcmail01.ecgcindia.com, webmail.ecgc.in, autodiscover.ecgcindia.com, autodiscover.ecgc.in, ecgc.in -PrivateKeyExportable $True
*******************************
Enable Disable Outlook Anywhere Access
set-casmailbox -mapiblockoutlookrpcthhp:$true
you can do:
get-user | set-casmailbox -mapiblockoutlookrpcthhp:$true
which will kill all access, and then go back and to a $false for the two in question to allow them to use it.
*******************************
To Create CAS Virtual directories using Exchange PowerShell
Get-OwaVirtualDirectory -server ecgcowa01 | Remove-OwaVirtualDirectory
New-OwaVirtualDirectory -Name "Exchange" -owaversion Exchange2003or2000 -VirtualDirectoryType Mailboxes -WebSiteName "Default Web Site"
New-OwaVirtualDirectory -Name "exadmin" -owaversion Exchange2003or2000 -VirtualDirectoryType exadmin -WebSiteName "Default Web Site"
New-OwaVirtualDirectory -Name "public" -owaversion Exchange2003or2000 -VirtualDirectoryType PublicFolders -WebSiteName "Default Web Site"
New-OwaVirtualDirectory -Name "owa" -owaversion Exchange2007 -WebSiteName "Default Web Site"
New-OwaVirtualDirectory -Name "exchweb" -owaversion Exchange2003or2000 -VirtualDirectoryType exchweb -WebSiteName "Default Web Site"
*******************************
Move Mailbox
Move-Mailbox -TargetDatabase "ecgcmail01\ECGC Users\webmail user" -Identity "ED" -preservemailboxsizelimit
Y
*******************************
Export Mailbox in PST
Export-Mailbox -pstfolderpath d:\andy\pst\ -identity "Ashok Dichwalkar"
Y
*******************************
cls
Get-MailboxStatistics -Database "ecgcmail01\general users\mailboxes" | Sort-Object TotalItemsize -Descending | Where {$_.TotalItemSize -gt 65MB} | ft Displayname , TotalItemSize
Get-MailboxStatistics -Database "ecgcmail01\webmail users\mailboxes" | Sort-Object TotalItemsize -Descending | Where {$_.TotalItemSize -gt 145MB} | ft Displayname , TotalItemSize
cls
Get-MailboxStatistics -Database "ecgcmail01\webmail users\mailboxes" | Sort-Object TotalItemsize -Descending | Where {$_.TotalItemSize -gt 145MB} | ft Displayname , @{expression={$_.TotalItemSize.Value.ToMB()}}, StorageLimitStatus
Get-MailboxStatistics -Database "ecgcmail01\general users\mailboxes" | Sort-Object TotalItemsize -Descending | Where {$_.TotalItemSize -gt 65MB} | ft Displayname , @{expression={$_.TotalItemSize.Value.ToMB()}}, StorageLimitStatus
*******************************
update 10K Photo in AD
Import-RecipientDataProperty -Identity "Bharat Suneja" -Picture -FileData ([Byte[]]$(Get-Content -Path "C:\pictures\BharatSuneja.jpg" -Encoding Byte -ReadCount 0))
**************************************
Enable OWA for list of users
$path = "d:\Andy\Owa.txt"
foreach ($line in Get-Content $path) { Set-CASMailbox –Identity $line –OWAEnabled:$true }
**********************************************
Logon Statastics Report
Get-LogonStatistics -Server "ecgcmail01" | Sort-Object Logontime –Descending | ft userName , Logontime
*******************************
List of Databases
Get-Mailbox -Database "ecgcmail01\general users\mailboxes" |Sort-Object Name –Descending
*******************************
Move all Mailboxes from database
Get-Mailbox -Database "ecgcmail01\ecgc users\general user" |Move-Mailbox -TargetDatabase "ecgcmail01\general users\mailboxes" -PreserveMailboxSizeLimit
*******************************
List Group Members
Get-QADGroupMember -Identity ITCoordinators
*******************************
For Logon Details
$last30d = (Get-Date).Subtract((New-TimeSpan -Days 15))
get-mailboxstatistics -Server ecgcmail01 | where {$_.lastlogontime -lt $last30d} | Ft Displayname , lastlogontime
*******************************
Add User to Group
Add-QADMemberOf -Group "Internet users" -Identity "ecgcindia\sukhan.singh"
*******************************
Get all disconnected mailboxes
Get-MailboxStatistics | where-object { $_.DisconnectDate -ne $null } | Select DisplayName,MailboxGuid
*******************************
Remove a single disconnected mailbox
Remove-Mailbox -Database <Database-Name> -StoreMailboxIdentity <MailboxGuid> -confirm:$false
*******************************
Remove all disconnected mailboxes
$users = Get-MailboxStatistics | where-object { $_.DisconnectDate -ne $null } | Select DisplayName,MailboxGuid,Database
*******************************
Update GAL
Update-GlobalAddressList -identity "Default Global Address List"
*******************************
Certificate Request
New-ExchangeCertificate -GenerateRequest -Path c:\webmail_ecgc_in.csr -KeySize 1024 -SubjectName "c=IN, s=Maharashtra, l=Mumbai, o=Export Credit Guarantee Corporation of India, ou=MAIL SERVER, cn=webmail.ecgc.in" -DomainName ecgcindia.com, ecgcowa01.ecgcindia.com, ecgcmail01.ecgcindia.com, webmail.ecgc.in, autodiscover.ecgcindia.com, autodiscover.ecgc.in, ecgc.in -PrivateKeyExportable $True
*******************************
Enable Disable Outlook Anywhere Access
set-casmailbox -mapiblockoutlookrpcthhp:$true
you can do:
get-user | set-casmailbox -mapiblockoutlookrpcthhp:$true
which will kill all access, and then go back and to a $false for the two in question to allow them to use it.
*******************************
To Create CAS Virtual directories using Exchange PowerShell
Get-OwaVirtualDirectory -server ecgcowa01 | Remove-OwaVirtualDirectory
New-OwaVirtualDirectory -Name "Exchange" -owaversion Exchange2003or2000 -VirtualDirectoryType Mailboxes -WebSiteName "Default Web Site"
New-OwaVirtualDirectory -Name "exadmin" -owaversion Exchange2003or2000 -VirtualDirectoryType exadmin -WebSiteName "Default Web Site"
New-OwaVirtualDirectory -Name "public" -owaversion Exchange2003or2000 -VirtualDirectoryType PublicFolders -WebSiteName "Default Web Site"
New-OwaVirtualDirectory -Name "owa" -owaversion Exchange2007 -WebSiteName "Default Web Site"
New-OwaVirtualDirectory -Name "exchweb" -owaversion Exchange2003or2000 -VirtualDirectoryType exchweb -WebSiteName "Default Web Site"
*******************************
Move Mailbox
Move-Mailbox -TargetDatabase "ecgcmail01\ECGC Users\webmail user" -Identity "ED" -preservemailboxsizelimit
Y
*******************************
Export Mailbox in PST
Export-Mailbox -pstfolderpath d:\andy\pst\ -identity "Ashok Dichwalkar"
Y
*******************************
cls
Get-MailboxStatistics -Database "ecgcmail01\general users\mailboxes" | Sort-Object TotalItemsize -Descending | Where {$_.TotalItemSize -gt 65MB} | ft Displayname , TotalItemSize
Get-MailboxStatistics -Database "ecgcmail01\webmail users\mailboxes" | Sort-Object TotalItemsize -Descending | Where {$_.TotalItemSize -gt 145MB} | ft Displayname , TotalItemSize
Comments