Exchange 2007/2010 – Custom System message – HTML format

Exchange 2010/2007 provides you the option to send the custom system messages. You can customize the message which users get when his mailbox quota is getting to close to the limits. Default warning message does give some information. If you wanted to add more data like steps to delete unwanted email, link to your internal email policy etc. These things can be done easily with new-systemmessage or set-systemmessage

Below is the example of the same. Remove-systemmessage removes the existing default warning message.

$K has all the data which you wanted to be in the warning message, it has link, message with different bold and colour. You can include any basic HTML stuff to format the data.

New-systemmessage helps us to assigning the HTML data into the system for warning mailbox

Remove-SystemMessage En\WarningMailbox

$K=@"
<BR><b> <font Size="3" color="RED" Face="Arial"> You will have problem sending email if you do not delete your unwated emil</b> </Font></BR> <br>Make sure that you delete your unwated and deleted items from your mailbox </br><br> <A HREF='http://Internalportal'>Company email policy</A></BR>"@

New-SystemMessage -QuotaMessageType WarningMailbox -Language En -Text $K

Powershell to work on Remote Registery

Working on Remote Registry is always challenging. If you are administrator, I am sure you would have come across various times that you wanted to update registry of the computer and you have to login to the each server and apply the registry. Powershell has made most of our administrator’s life easier. Let’s understand how we can access and edit registry of remote computer using powershell

Let’s understand code with example. Below Script take the list of server name in CSV file and reads each server name one by one and opens the registry Key and prints the value. In this fashion you can get any key and get the value. In the below script I am trying to get the value of HKEY_CurrentUsers. This is the reason current in OpenRemoteBaseKey. If you Access keys of HKEY_Localmachine and use LocalMachine


$csv = Import-Csv "C:\Server.csv"
foreach($line in $csv)
{
 $strComputer = $line.CMSName
 $curreg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('CurrentUser', $strComputer)
 $curkey="Software\Microsoft\Windows\CurrentVersion\Wintrust\Trust Providers\Software Publishing"
 $curregKey = $curreg.OpenSubKey($curkey)
 $curregkey.GetValue('State')
} 

If you wanted to get the list of subfolder under the folder in the registry then use the below code. This will get list of all the subfolder MSExchangeIS\Clustername. Getsubkeynames() does this.


<strong>$csv = Import-Csv "C:\Server.csv"
foreach($line in $csv)
 {
 $cmsName = $line.Node
 $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $strComputer)
 $key="SYSTEM\CurrentControlSet\Services\MSExchangeIS\$cmsName"
 $regKey = $reg.OpenSubKey($key)
 foreach($Rkey in $regKey.getsubkeynames())
  {
  $Rkey
   }
 }

If you wanted to write or edit the remote registry then below code will help. This code will create the new key if the key does not exist else it will edit the existing key to the required value. Below code will create the Dword key if key does not exit there else it will edit the existing key to the required value on the entire computer mentioned in the CSV file.

$csv = Import-Csv "C:\Server.csv"
foreach($line in $csv)
{
 $strComputer = $line.Node
 $curreg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('CurrentUser', $strComputer)
 $curkey="Software\Microsoft\Windows\CurrentVersion\Wintrust\Trust Providers\Software Publishing"
 $curregKey = $curreg.OpenSubKey($curkey,$True)
 $curregkey.SetValue('State','100234','Dword')
}