Powershell check if Remote Machine Required Port is opened or Not

December 8, 2009

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

http://www.microsoft.com/downloads/details.aspx?FamilyID=89811747-C74B-4638-A2D5-AC828BDC6983&displaylang=en

$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

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


PortQuery to Check Port Status on Remote and Local Computer

December 8, 2009

Download the copy of the portQry from the below link

http://www.microsoft.com/downloads/details.aspx?FamilyID=89811747-C74B-4638-A2D5-AC828BDC6983&displaylang=en

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

December 8, 2009

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=Services
CN=Microsoft Exchange
CN=Your_Organization_Name
CN=Administrative Groups
CN=Your_Administrative_Group_Name
CN=Servers
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


Exchange 2007 IMAP and POP Protocol Logging

December 7, 2009

IMAP and POP Protocol logging is made easy in Exchange 2007. Below are the step by step to enabled the same.

1. Login to Exchange 2007 client access server
2. Browse to C:\Program Files\Microsoft\Exchange Server\ClientAccess\PopImap
3. Open Microsoft.Exchange.Imap4.exe.config with notepad
4. Find the <addkey=”ProtocolLog” value=”false” /> in the file
5. Change False to True
6. Below link <add key=”LogPath” value=”C:\Program Files\Microsoft\Exchange Server\Logging\Imap4″ /> is the path of the Imap4 log file location
7. Restart MSExchangeIMAP Service


Configure GALSync (ILM 2007 SP1) Between Exchange 2007 Cross forest

December 3, 2009

Domain Setup

A Domain
1. One DC with DNS
2. One Exchange 2007 with CAS,HUB and Mailbox Server roles installed

 K Domain
1. One DC with DNS
2. One Exchange 2007 with CAS,HUB and Mailbox Server roles installed
3. Windows 2003 for ILM 2007 SP1   – Prereqists Powershell, Exchange 2007 Management , Exchange 2005 – With SP1

To configure Mail flow between forest

1. Configure DNS forwared for A.com and K.Com for DNS resolution
2. Login to ADC and open DNS Services and Properties
3. Forwarders and IP address for K.com

4. Once this is done perform the same steps on KDC and configure forderwares for A.com

5. Then configure forest trust. Open Active Directory Domain and trusts on KDC to configure two way forest trust between two forest

6. Create Internal Send Connector between two exchange forest
http://technet.microsoft.com/en-us/library/bb123546.aspx

7. Create OU for GALsyncronisation in both the domain. Below is the OU Path to dump the contacts from the Target Forest

     OU=Contacts,OU=K,OU=GALSyncronisation,DC=A,DC=Com
     OU=Contacts,OU=A,OU=GALSyncronisation,DC=K,DC=Com

8. Login to Ksync make sure that you have installed with Powershell 1.0, Exchange 2007 management console and SQL 2005 SP1

9. Install ILM 2007 SP1 default isntallation

10. Open Identity Manager

11. Click on Management Agents and click Create

12. Select Active Directory Global Address List(GAL) and provide the appropriate Name

13. Enter the domain name , forest name and credentials for target domain click next to continue

14. On Configure Directory Partition select Containers. On the Select Containers page, clear the top-level check box for the directory partition, select the containers for which this management agent will gather and store information, and then click OK. Make sure that you point to OU=Contacts,OU=A,OU=GALSyncronisation,DC=K,DC=Com

15.Select the Target path as show below and click on Source to Select the source ou where users , contacts and groups are residing. Make sure that Route mail throught this forest for all the contact from the contacts in this forest  and Support Cross-Forest delegation(Exchange 2007 only) is checked

16. Click Next until you get the last page Configure Extention and make sure that you Check Enable Exchange 2007 Provisioning and click finish

17. Create the Similar Management Agent AGAL for sync objects from K domain to A domain. Below is the snap of the Management Agents for both the domain

18. Right click on each of the MA Created above and select run and select blow option one by one
Full Import (Staging Only)
Full Synchronization
Export
Delta Import

19. This completes our Configuration of ILM. Select an Each of the domain to make sure that Contacts are created in the target forest for the respective objects from the source forest

20. Reference Articles

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

ILMFP1_SS_GalSync


Poweshell to remove all Secondary Email address for given set of users

November 27, 2009

Below powershell helps to pull out all the  secondary email address for the given set of users

Get-Content C:\users.txt|Get-Mailbox | foreach {
for ($i=$_.EmailAddresses.Count;$i -ge 0; $i–)
{
$_.EmailAddresses[$i].ProxyAddressString

if ($_.EmailAddresses[$i].ProxyAddressString  -like “smtp:*” )
{
$_.EmailAddresses.RemoveAt($i)
}

}
$_|set-mailbox
}


Send-MailMessage – Exchange 207 sp2 and Exchange 2010

November 26, 2009

Sending email throught command had multiple steps,  now Exchagne 2007 SP2 which works on Powershell V2 has introduced a new cmdlet Send-Mailmessage. Sending email with Send-MailEssage is just single line command Below is the example of the same

Send-MailMessage –From Krishna.k@domain.com –To Rajesh@domain.com –Subject “Send-MailMessage Test” –Body “Send-MailMessage Test”  -Attachments “c:\Attachment.txt” –SmtpServer Hubserver.domain


Powershell to Get all the Exchange Services Status

November 26, 2009

Powershell check can pull all the Exchange Services status runing on the exchange 2007 Servers

$Exchserver = “<Servername>”
$ExchServices = (gwmi -computer $Exchserver -query “select * from win32_service where Name like ‘MSExchange%’ or Name like ‘IIS%’ or Name like ‘SMTP%’ or Name like ‘POP%’ or Name like ‘W3SVC%’”)
$Services = @()
Foreach ($Service in $ExchServices){
$Service.Caption
$Service.Startname
$Service.StartMode
$Service.State
}


Powershell to check last window login time on all user accounts who has mailbox

November 13, 2009

Powershell to check last window login time on all user accounts who has mailbox in Exchange Server. Below commands need to be executed on the Activel Roles cmd Shell. Its using Get-QADUser to find all the required details

Get-QADUser -IncludeAllProperties |?{($_.msexchhomeservername -ne $null) -and $_.LastLogonTimestamp -lt (get-date).AddDays(-30)} | select name,LastLogonTimestamp


Powershell to formally disable user accounts who have left Orginization

November 11, 2009

When user leaves orginization administrators make sure that account is disabled and its marked for deletion. Delection can happen once in 15 days or 1 month.  We may need to perform series of steps for disabling the account

eg. Disable Account, Move Object to Disabled Account OU, Hiding from GAL, removing Group members, 0 ing send and receive limits.

Below powershell script helps to perform the same.  It uses both Exchange commands and Quest Active roles command lets. We need to add the snapin to execute the code.

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
Add-PSSnapin Quest.ActiveRoles.ADManagement
$AName = Read-Host “Enter User Alias name for Disable”
$AName | out-file -filePath E:\users.txt
foreach ($user in (get-content E:\users.txt)){(get-qaduser $user).memberof | Get-QADGroup | where {$_.name -ne “domain users”} | Remove-QADGroupMember -member $user}
Move-QADObject $user -NewParentContainer “domain.com/Disabled Accounts”
Disable-QADUser $user
Set-Mailbox $user  -HiddenFromAddressListsEnabled $true -UseDatabaseQuotaDefaults:$False -issuewarningQuota 0MB -ProhibitSendQuota 0MB -ProhibitSendReceive 0MB

 

Below location has copy of the code

http://powershell.com/cs/members/smtpport25.wordpress/files/DisableUserAccounts.ps1.aspx