Exchange Tip: Exchange 2010 user profile statistics

Just to remeber for myself. There is nice script for mailbox profile information gathering in Exchange 2010.

http://blogs.technet.com/b/neiljohn/archive/2011/08/09/user-profile-analysis-for-exchange-server-2010.aspx

Thanks Neil.

 

Advertisements

Exchange Tip: How to save your Exchange objects

If you are going to change mailbox properties by a script, you will need to be ready to roll back the change smoothly without delay. It means to have a recovery procedure.

Basically if you change any mailbox object (it can be applied to any PS object), you should save it before because of recovery or reporting purpose.

[PS] C:\> $mbx = Get-Mailbox "filip"

Well, we used variable $mbx to store object Get-Mailbox “filip”.

The variable contains fully-described object (properties, methods, values).

[PS] C:\> $mbx.EmailAddresses[0].Prefix.PrimaryPrefix 
SMTP

The variable and its data is defined by each Windows PowerShell provider. It means that it is alive based on provider memory and related session.

So how can we save it permanetly? We would export the object from PowerShell into the disk.

Object can be described by many ways but xml is most suitable format for representing our data structures and ensures also fully-described view. (Import-Clixml, Export-Clixml)

[PS] C:\> Get-Mailbox "filip" | Export-Clixml -Encoding unicode -path "D:\filip.xml"

The size of D:\filip.xml is about 0.6 MB (for 5 mailbox objects it is 0.96 MB), do not count 0.6 MB per mailbox.

[PS] C:\>(Get-Item D:\filip.xml).Length / 1MB
0.623746871948242

We have saved the mailbox and we can change for example its email addresses or anything else.

[PS] C:\> Set-Mailbox "filip" -EmailAddresses "SMTP:filip.kasaj@contoso.com"

After that we can revert the email addresses by D:\filip.xml anytime.

[PS] C:\> $f = Import-Clixml -Path "D:\filip.xml"
[PS] C:\> Get-Mailbox "filip" | Set-Mailbox -EmailAddresses $f.EmailAddresses

Well, feel free to use us the same procedure for any mass change regarding to server or recipient configuration and save your nerves during recovery.

Example:

$mailboxes = get-mailbox -ResultSize unlimited 
$mailboxes | Export-Clixml -Encoding unicode -path "D:\mailboxes.xml"
$mailboxes | Set-Mailbox -EmailAddressPolicyEnabled $True

##

$mailboxes = Import-Clixml -Path "D:\mailboxes.xml"
foreach($mailbox in $mailboxes){
    Set-Mailbox -Identity $mailbox.Identity -EmailAddresses $mailbox.EmailAddresses -EmailAddressPolicyEnabled $mailbox.EmailAddressPolicyEnabled
}

Exchange Tip: Exchange Virtual Directory URLs

Here is a one-line cmdlet for gathering all Exchange Virtual Directory URLs:

Get-ActiveSyncVirtualDirectory
Get-AutodiscoverVirtualDirectory
Get-EcpVirtualDirectory
Get-OabVirtualDirectory
Get-OwaVirtualDirectory
Get-PowerShellVirtualDirectory
Get-WebServicesVirtualDirectory

Get-Command -Verb "Get" -Noun "*VirtualDirectory"|%{Invoke-Expression -Command "Get-ClientAccessServer | $_ -ADPropertiesOnly |select server,name,*ternalUrl"}|sort -Property server

6- 11- 2013 11-53-55