Update-ConfigFiles.ps1

So inlight of RU5 I thought I would share this with you.  So we know the issue with the .net framework and the Certicate Revokation List.

This script updates the Exchange 2007 .config files inline with 944752: Exchange Server 2007 managed code services do not start after you install an update rollup for Exchange Server 2007

It will add the following in to all .config files (except web.config).  It will also backup the original file before update

 
  
 

REMEMBER test in the lab before production

Update Rollup 5 for Exchange Server 2007 Service Pack 1 (KB953467)

The whole universe knows by now that RU5 for Exchange 2007 SP1 has hit the streets.

You can download it here: http://www.microsoft.com/downloads/details.aspx?FamilyID=652ed33a-11a1-459c-8ffe-90b9cbfe7903&DisplayLang=en

Ninob over at the Exchange team blog says that it will be out via Microsoft Update in the next few weeks.  He also mentions another good point, that is you want RU5 to install in minutes and NOT HOURS check out 944752: Exchange Server 2007 managed code services do not start after you install an update rollup for Exchange Server 2007.  Check out my post on a script that will do this for you.  However RU5 will do the update too

You can check the KB out here: 953467: Description of Update Rollup 5 for Exchange Server 2007 Service Pack 1.  Revision 1.1 lists 48, yeah thats right 48 fixes!

This looks good : 949722 – Event ID 800 does not include the user name of users who ran the Get-MessageTrackingLog command in an Exchange 2007 environment <http://support.microsoft.com/kb/949722/>

Send-Mail.ps1 v3.2 [7 November 2008]

v3.0 6 August 2008     : Removed the GUI form the original script
v3.1 22 August 2008 : Updated to “autofind” a hub server if -server is not specified
v3.2 7 November 2008 : Some minor tweeks. Added event logging.Added Error Event logging

This script uses .net (System.Net.Mail.MailMessage) to send an email
 – Reports output to the Application EventLog with Event IDs of:
  18 Script Starting
 19 Script Finished
 1801 Details of sent message
 1802 Details of any errors

COMMANDLINE OPTIONS

No Commandline ………. This help text
-? …………………. This help text
-server &nbsp; .. Default is localhost. <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If you specify “AutoDiscover” a Hub Transport Server <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; will be randomly selected<BR>-from <EMAIL address>… From Email Address. Default is <A href=”mailto:nobody@send-mail.ps1″ mce_href=”mailto:nobody@send-mail.ps1″>nobody@send-mail.ps1</A><BR>-to <EMAIL address>….. TO email address<BR>-cc <EMAIL address>….. CC email address<BR>-bcc <EMAIL address>…. BCC email address<BR>-toCSV <CSV name file>.. CSV file with email address.<BR>-ccCSV <CSV name file>.. CSV file with email address.<BR>-bccCSV <CSV name file>. CSV file with email address.<BR>-subject <TEXT>……… Message Subject. <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Default value will be set if not specified<BR>-body <TEXT>………… Message Body. <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Default value will be set if not specified<BR>-attachment <PATH Filename and><BR>-msgcount <NUMBER>…… Number of messages to be sent.&nbsp; Default is 1<BR>-verbose ……………&nbsp; Turns on verbose mode</P> <P mce_keep=”true”>&nbsp;</P></FONT>

get-hotfix.ps1 v1.5 [7 November 2008]

Okay I have updates as follows:

v1.0 27 October 2008 : A Script is born
v1.1 28 October 2008 : Add ability to expose Server Model
v1.2 31 october 2008 : Added email and commandline
v1.3 4 November 2008 : Added option to check recent changes
v1.4   6 November 2008 : Days commandline added
v1.5   7 November 2008 : Added option to check exchange cluster nodes

This script will check all Exchange 2007 servers and enumerate the Exchange Patch information and list the windows updates installed on the server

list hotfixes for all exchange servers
.Get-Hotfixes.ps1

list hotfixes for just the names server
.Get-Hotfixes.ps1

list hotfixes for all exchange servers and include cluster nodes and localhost. Additionally colour in red fixes that happened in the last 10 days
.Get-Hotfixes.ps1 -localhost -cluster -days 10 

For emailing to work the script requires send-mail.ps1 in the same folder

CAS vdir restore using PowerShell

Wow is all I have to say, this is a damm excellent article and script .. check it out:

http://technet.microsoft.com/en-us/library/bb124359.aspx

Basically, it’s a script that will recreate your owa virtual directories from a previous xml export! ..I just added a comment .. to create the export run:

Get-ClientAccessServer | Get-OwaVirtualDirectory | ForEach{$x="";$x+=$_.Server;$x+="_";$x+=$_.Name;Write-Host $x;Get-OwaVirtualDirectory $_ | Export-Clixml "$x.xml"}
 I can feel an update to get-exchangeserverplus coming very soon!

Symantec Enterprise Security Manager and Exchange 2007 CCR Clusters

Bit off my normal subjects, but I has an issue with registering Symantec Enterprise Security Manager on my Exchange 2007 CCR Clusters.

Essentially when I attempted to register ESM on each node of an Exchange 2007 CCR cluster and I keep getting:

C:Program Files (x86)SymantecESMbinw3s-ix64>register -rAvF -m -U register -P -N
Registering to manager
error connecting to ESM manager

the “NONE” transport layer is not supported on this operating system
error getting the default protocol
WIN32 error (193)

The trick (Thanks to Rupali on the Symantec forums) was to just add a t to the command line which adds the TCP protocol.

C:Program Files (x86)SymantecESMbinw3s-ix64>register -rAvFt -m -U register -P -N

Get-MailboxStatistics with TotalItemSize in MB to a CSV file

Just ignore this, I wanted to store this code snippet somewhere and this was the best place.  But if you are interested this will create a csv file from Get-MailboxStatistics, but with the TotalItemSize in MB

“DisplayName,TotalItemSize(MB),ItemCount,StorageLimitSize,Database,LegacyDN” | out-file GMS.csv; get-mailbox -resultsize unlimited | Get-MailboxStatistics | ForEach{$a = $_.DisplayName;$b=$_.TotalItemSize.Value.ToMB();$c=$_.itemcount;$d=$_.storagelimitstatus;$e=$_.database;$f=$_.legacydn;”$a,$b,$c,$d,$e,$f”} | out-file GMS.csv -Append

Scheduling a Powershell Command

Just wanted to share this with you all.

So I have a number of scripts that I schedule to run either every 10 min, once a day or once a week.  It’s simple really, I create .cmd file that I then use the task scheduler or schtasks to create. 

Inside the .cmd file I have this:

powershell c:psTest-ExchangeServers.ps1 -localhost -testsmtp

That’s it .. well almost.  If the script needs to use any exchange commands, you need to add the exchange snap in.  To do that you need to add this to your .ps1 file.  The following command check to see if the snapin is loaded and if not it loads it.  That why  if you start the Exchange Management Shell it will no try to add the already loaded snapin

$xPsCheck = Get-PSSnapin | Select Name | Where {$_.Name -Like “*Exchange*”}; If ($xPsCheck -eq $Null) {Add-PsSnapin *Exchange*}

Enjoy

Exchange Powershell and Whatif

So I have been creating a few scripts to automate the configuration of exchange, and wanted to use the -WhatIf switch so you can see what would or would not change.

-WhatIf []
The WhatIf parameter instructs the command to simulate the actions that it would take on the object. By using the WhatIf parameter, you can vi ew what changes would occur without having to apply any of those changes. You don’t have to specify a value with the WhatIf parameter.

Now typically you would just use the -whatif switch after the command, but I just wanted one command and have the ability to turn on or off the switch, but keep the same line of code.

So I had a brain storm on the way in to work this morning and after a little try found out something (which If I have read the help listed above would have come quicker!)

So here we go, you can specify a $true or $false after the -WhatIf switch.  So what  you say, well you can pass that via a variable and that make things a whole lot more fun. so … the key here is the colon between -WhatIf and $True or $False

-WhatIf:$False

$xWhatIf = $true

Get-TransportServer LONINMEXD02  | Set-TransportServer -OutboundConnectionFailureRetryInterval 00:10:00 -WhatIf:$xWhatIf

What if: Setting transport server “loninmexd02.uk.db.com”.

** Value is not set **

$xWhatIf = $false

Get-TransportServer LONINMEXD02  | Set-TransportServer -OutboundConnectionFailureRetryInterval 00:10:00 -WhatIf:$xWhatIf

** Value IS set **

Sweet!