Exchange Server Share

December 19, 2008

Exchange 2007 SP1 UR5 & WSUS

You would have noticed that when WSUS detects Exchange 2007 SP1 UR5 it has 1364MB in size whereas manual download on Microsoft site has only 66MB for English language.

You may verify it in Microsoft Update catalog.
http://catalog.update.microsoft.com/v7/site/Search.aspx?q=Exchange%202007%20SP1%20update%20rollup%205

image

Manual download: http://www.microsoft.com/downloads/details.aspx?FamilyId=652ED33A-11A1-459C-8FFE-90B9CBFE7903&displaylang=en

image 

Reason: There could be a mistake in the automation part which creates the Microsoft Update XML for WSUS and resulted in this issue.

Issue: The WSUS server that only wants supported language patches (for example just English patches), cannot get requested updates from Microsoft Updates site and then be forced to download updates for all languages which is 1364MB in size.

This will be fixed in the next Update Rollup meanwhile you are concerned about this UR5 then there are two options…

  • Once UR5 is deployed on all servers through WSUS, remove the rollup from WSUS server to release the space.
  • Download Exchange 2007 SP1 UR5 manually and update the Exchange servers to avoid full download on WSUS server.

December 10, 2008

PowerShell: Export Multivalued Properties

Filed under: Exchange, Exchange 2007, PowerShell, Script — Amit Tank @ 3:31 pm
Tags: , , ,

You would have seen that, when we try to export multivalued property to CSV file with Export-CSV command, it just copies Definition instead of all the values of that multivalued property.

Let’s take couple of examples…

Example 1: Export Blocked Recipients from the Recipient Filtering configuration.

When we export Blocked Recipients with below command, it exports Definition of the BlockedRecipients property instead of all the values because it is a multivalued property.

Get-RecipientFilterConfig | Select Name, BlockedREcipients | Export-CSV BlockedRecipient.csv

image

image

Resolution:

We need to join all the values of multivalued property with Join function before exporting it.

So our final command to export all the values of BlockedRecipients multivalued property is below.

Get-RecipientFilterConfig | Select Name, @{Name=’BlockedRecipients’;Expression={[string]::join(";", ($_.BlockedREcipients))}} | Export-CSV BlockedRecipient.csv 

image

image 

Example 2: Export all the email addresses of a user.

When we export the EmailAddresses property with below command, it just exports Definition.

Get-Mailbox "Tank, Amit M" | Select Name, EmailAddresses | Export-CSV EmailAddress.csv

image

So we need to join all the email addresses before exporting to CSV file and our final command is below.

Get-Mailbox "Tank, Amit M" | Select Name, @{Name=’EmailAddresses’;Expression={[string]::join(";", ($_.EmailAddresses))}} | Export-CSV EmailAddress.csv

image

This would be even more helpful when we want to export a multivalued property for bulk of users, like when we export email addresses of all the users of an Exchange environment with below command.

Get-Mailbox | Select Name, @{Name=’EmailAddresses’;Expression={[string]::join(";", ($_.EmailAddresses))}} | Export-CSV EmailAddress.csv

December 8, 2008

How To: Schedule PowerShell Script for an Exchange Task

Filed under: Exchange, Exchange 2007, PowerShell — Amit Tank @ 3:31 pm
Tags: , ,

This is commonly asked question, How to schedule a PowerShell script to run an Exchange task automatically? Here is the procedure to get it done.

Let’s take an example, I want to schedule a PowerShell script for auditing purpose, which scans whole environment & finds mailboxes which has some Send-As permission assigned and send the CSV formatted report to email id every Monday 9:00AM.

1. Set the PowerShell environment.

We need to set environment to run custom PS1 script which we created because by default PowerShell doesn’t allow to run it.

By default Execution Policy is ‘Restricted’ which means it does not load configuration files to run custom scripts. We need to change it to ‘RemoteSigned’ to run locally created PS1 scripts however RemoteSigned policy requires PowerShell script that may be downloaded must be signed.

This is one time activity so if you have already set the execution policy to RemoteSigned earlier then you can skip this step.

Run below command in ESM to set the execution policy.

Set-ExecutionPolicy RemoteSigned

image

2. Create a Script file (.PS1 file).

Here is the script to get the Send-As report in email.

# Send-As.ps1 - Get the report of all mailboxes with Send-As permission assigned on email.
# Created by - Amit Tank 
 
#Adding Exchange Snap In to execute Exchange CmdLets in this script
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
 
#Get Send-As permission report to CSV file
Get-Mailbox | Get-ADPermission | where { ($_.ExtendedRights -like “*Send-As*”) -and ($_.IsInherited -eq $false) -and -not ($_.User -like “NT AUTHORITY\SELF”) } | Select Identity, User, Deny | Export-CSV c:\send-As.csv
 
#Send an email
$FromAddress = "amit.tank@Domain.com"
$ToAddress = "amit.tank@Domain.com"
$MessageSubject = "Send-As Audit Report"
$MessageBody = "Attached is CSV file for Send-As audit report"
$SendingServer = "HubTransportServerName"
$SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress, $ToAddress, $MessageSubject, $MessageBody
$Attachment = New-Object Net.Mail.Attachment("c:\Send-As.csv")
$SMTPMessage.Attachments.Add($Attachment)
$SMTPClient = New-Object System.Net.Mail.SMTPClient $SendingServer
$SMTPClient.Send($SMTPMessage)

Note: Change the FromAddress, ToAddress and ExchangeServerName in above script as per your environment if you are going to use same script.

It requires to add Exchange Management Snap-In to recognize Exchange CmdLets in PowerShell so make sure that below line is added into script.

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin

You can refer below article for more detail about one liner cmdlet on getting a CSV formatted report of Send-As permissions assigned mailboxes.

How To: Find All Mailboxes with Send-As

3. Create a CMD/Bat file to execute the script.

Create a CMD/Bat file to execute PowerShell and pass the path of script with ‘-command’ switch.

Powershell -command "& {C:\Scripts\Send-As\Send-As.ps1 }"

 

image

4. Create a Schedule Task.

Create a schedule task and give the Bat file path to run. Set the password which has proper permission to execute the Exchange CmdLets available in script file.

image

Schedule this to run every week at specified time (9:00AM).

image

Well all things are set, now this mechanism runs every Monday 9:00AM and it will send a required report to mentioned email id.

Blog at WordPress.com.