Showing posts with label Powershell. Show all posts
Showing posts with label Powershell. Show all posts

Find parent path to a mail enabled public folder

2 Kommentare
In EMC of Exchange 2010 you can use the following command to show the parent path to a mail-enabled public folder:

get-recipient address@domain.com | Get-MailPublicFolder  | Get-PublicFolder

Name                                         Parent Path
----                                         -----------
address@domain.com                           \folder1\folder2

Version 1.3.2 of Ex2010_MBDB_Info released

5 Kommentare

Again I've released a new version of the check. I've changed only the Windows plugin. Now the spaces in a mailbox database name are replaced by underscores. I hope this change would help all of you, who experienced problems with the plugin.

To update it's enough to download the new check package, install it in your check_mk instance by a command like this:

cmk -vP install Ex2010_MBDB_Info-1.3.2.mkp

and substitute the cmd file on your Exchange server by the Ex2010_MBDB_Info.ps1 file from the new package.

You can find the new version of the package at the known place at the check_mk plugin exchange site.

Version 1.3.1 of Ex2010_MBDB_Info released

14 Kommentare
I've released a new version of the check. I've changed the Windows plugin. It is now a pure Powershell script, not a command script anymore. It should run smoothly to avoid problems, which some of you had in the past running the plugin.
To update it's enough to download the new check package, install it in your check_mk instance by a command like this:

cmk -vP install Ex2010_MBDB_Info-1.3.1.mkp

and substitute the cmd file on your Exchange server by the Ex2010_MBDB_Info.ps1 file from the new package.

You can find the new version of the package at the known place at the check_mk plugin exchange site.

Find differences in Public Folder replicas

0 Kommentare
This is a small piece of code to run it in EMS and to help you finding differences in item number in a public folder structure. The powershell script shows the number of elements in each sub folder for the both of Exchange 2010 servers, which public folder replicas are located on. Below is an example output of the script.


[PS] C:\>C:\scripts\get-pffolderdiffs.ps1

Path                                       ItemCount_SRV1 ItemCount_SRV2
----                                       -------------- --------------
\PF1\VPC                                                 0             0
\PF1\VPC\Exec                                         1739          1739
\PF1\VPC\Exec\2007                                   20406         20406
\PF1\VPC\Exec\2008                                   21952         21952
\PF1\VPC\Exec\2009                                   27804         27804
\PF1\VPC\Exec\2010                                   16888         16888
\PF1\VPC\Exec\2011                                   39021          1869
\PF1\VPC\Exec\2012                                   15734         15734

Please note that the script is provided AS IS without any guarantee:


$PF='\PF1'
$SR1='SRV1'
$SR2='SRV2'


Get-PublicFolder -Server $SR1 -ResultSize unlimited -Identity $PF -Recurse `
  | Sort-Object -Property @{expression={$_.ParentPath + '\' + $_.Name}} |
ft @{label="Path"; expression={ $_.ParentPath + "\" + $_.Name }},
   @{label="ItemCount_$SR1"; expression={ `
     (get-PublicFolderStatistics -Server $SR1 ($_.ParentPath + '\' + $_.Name) `
  | Select-Object -ExpandProperty ItemCount) }}, `
   @{label="ItemCount_$SR2"; expression={ `
     (get-PublicFolderStatistics -Server $SR2 ($_.ParentPath + '\' + $_.Name) `
  | Select-Object -ExpandProperty ItemCount) }} -auto



Transport-Rule in Exchange 2010 to prefix the Subject

0 Kommentare
Assume, you'd like to prepend the subject of an e-mail with a prefix, if the e-mail has been sent from the certain computer and if it has a certain sender name. In this case you can create a new transport rule with Powershell.

For example, the subject should be prepended by the phrase '[Alert]', if the From address contains 'my_sender@company.com' AND if the computer's name, which the email is sent from, is 'my_computer.company.com'. The powershell command below configures this:

New-TransportRule
-Name 'My_transport_rule' -Comments 'My comment'
-HeaderContainsMessageHeader 'Received' -HeaderContainsWords 'my_computer.company.com '
-FromAddressContainsWords 'my_sender@company.com' -PrependSubject "[Alert] "

After the command has been executed the rule is active. It acts in the whole Exchange organization and is not restricted to a single server.

Please note that the argument for the parameter -HeaderContainsWords must contain the name, which the email program on the sender computer actually uses. If the new rule doesn't work as expected, look into the internet headers of a test e-mail and note the computer name, which is in the line Received.

Exchange 2010 Mailbox Database Move

0 Kommentare
It’s very easy to move a mailbox database in Exchange 2010 to a new location. Either you use EMC or you use the cmdlet Move-DatabasePath in EMS. Exchange 2010 would unmount the mailbox database to be moved (it’s unavailable all the moving time), copy the database file, the catalogs, remove them and last mount the mailbox database and set it online.

I prefer to use the cmdlet to move the mailbox database in Exchange 2010:

Move-DatabasePath -Identity 'MailDB' -EdbFilePath 'D:\MailDB\MailDB.edb' 
                  -LogFolderPath 'D:\MailDB'

Please note that if you’re going to start moving the mailbox database by a script or batch file, you should you the following syntax to avoid questions:

Move-DatabasePath -Identity 'MailDB' -EdbFilePath 'D:\MailDB\MailDB.edb' 
                  -LogFolderPath 'D:\MailDB' -Confirm:$false -Force:$true

If you get the error while running the cmdlet:
This operation cannot be performed on a remote server. Please use the -ConfigurationOnly option and then manually move the files.
make sure that you're running the command above on the mailbox database server locally!