Powershell to create new A Record and MX record into DNS

Powershell to Add A record and MX record into DNS. Add all the values which are given in <>

$ServerName = <DNS ServerName>

$MXrec = [WMIClass]”\\$ServerName\root\MicrosoftDNS:MicrosoftDNS_MXType”
$server = “<DNSservername>”
$OwnerName = “<domain.Example>”
$ContainerName “<domain.Example>”
$RecordClass = $Null
$TTL = $Null
$Preference = 10
$MailExchange = “mail.domain.Example”
$$MXrec.CreateInstanceFromPropertyData($ServerName, $ContainerName,’
$OwnerName, $RecordClass, $TTL, $Preference, $MailExchange

$Arec = [WmiClass]”\\$ServerName\root\MicrosoftDNS:MicrosoftDNS_AType”
$server = “<DNSservername>”
$zone = “<zoneName>”
$name = “ArecordServerAddress”
$class = 1
$ttl = 3600
$address = “IPAddress”
$Arec.CreateInstanceFromPropertydata($server, $zone, $name, $class,’
$ttl, $address)

Powershell to Ping Given Rage of IP Address and Get the Status

Below Powershell helps to ping given set of ip address and get the result status and also provides the status of number of machines which are rechable

$ping = New-Object System.Net.NetworkInformation.Ping
$i = 0
1..255 | foreach { $ip = “192.168.1.$_”
$Res = $ping.send($ip)
if ($Res.Status -eq “Success”)
$result = $ip + ” = Success”
Write-Host $result

$Hosts = [string]$i + ” Hosts is pingable”

Write-Host $Hosts

Powershell to Pull out Exchange 2007 Mount Free Disk Details

In Exchange 2007 We have may have lots of DBs which we land up in creating multiple mount points instead of Drives for each Logs and Database. Below script helps to pull out the size and free size of all the mount point of the database . Change the servername and for loop with the number of Database you have.

$K = gwmi win32_volume -computername “Servername” |where-object {$_.name -like “C:\Mountpoints\DB*”}|select name,capacity,freespace

for ($i=0; $i -le 22; $i++)
$name = $K[$i].name
$Capacity = [math]::truncate($K[$i].capacity/1gb)
$freespace = [math]::truncate($K[$i].freespace/1gb)
$L = $name + ” ” + $Capacity  + ” ” + $freespace
write-output $L

Powershell check if Remote Machine Required Port is opened or Not

Need to make sure that PortQry is downloaded from the microsoft site and use below powershell script to check the same


$Servername = Read-Host “Enter the Servername”
$PortNumber = Read-Host “Enter the Port Number”
$K = .\PortQry.exe -n $Servername -e $PortNumber -p TCP
$L = $K -Match “LIS?”
 If($L -ne $null)
$res = $servername + ” has ” + $PortNumbe + “Opened”
Write-Host $res

$res = $servername + ” has ” + $PortNumbe + “Closed”
Write-Host $res

PortQuery to Check Port Status on Remote and Local Computer

Download the copy of the portQry from the below link


Below command checks if   Remote computer TCP Port 445 is open or closed
PortQry.exe -n <IPAddress> -e 80 -p TCP

Below command checks if Remote computer UDP Port 445 is open or closed
PortQry.exe -n <IPAddress> -e 80 -p TCP

Below command checks if Remote computer TCP and UDP Port 445 is open or closed
PortQry.exe -n <IPAddress> -e 80 -p BOTH

Below command check if all the local computer port is open
PortQry.exe -local

Uninstalling Exchange 2003 cluster Server

Make sure that  Following is not residing on Exchange 2003 which you wanted to decomission

1. No mailbox
2. Configure public Folder replica to other servers
3. Configure Free busy and OAB information to replication to other public folder
4. Move Offline Address book to other Exchange Server
5. Move RUS to other Exchange Server
6. Make sure Decomission server is not Bridge Head Server or Routing Group Master Server

Login to Active Node of Exchange Server
1. Open Cluster Admin
2. Open Exchange Cluster resource and take offline all the resources Except Exchange name and Exchange IP address
3. Right click on Exchange System Attendent Cluster Resource -> Click on Remove Exchange Virtual Server and click on OK to confirm the same
4. Once you remove System Attendent Cluster resource loging to passive node and Add remove programs to remove Exchagne 2003
5. Once passive node is done then login to Active node and uninstall Exchange Server
6. If you could not uninstall Exchange 2003 Gracefully then
7. Stop All the Exchange resources and change to startup type to Disabled
8. Open Registery Editor and remove all the exchange related information
9. Delete Exchange Setup folders in the path C:\program files\Exchsrvr
10. Open Adsiedit then Access configuration Container and browse to the below path and right click on the Exchange 2003 server object and delete
Configuration Container
CN=Configuration, DC=Domain_Name,DC=com
CN=Microsoft Exchange
CN=Administrative Groups
11. Link http://support.microsoft.com/kb/833396 has some details information on the details on the services that needs to be stopped,registery that needs to be deleted for step 7 and 8 above
12. Reinstall IIS on both the server