SMTP Port 25

Anything and Everything Related to Messaging and Collaboration, Active Directory and Scripting. It’s My Life!!!

Archive for November, 2009

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

Posted by Krishna - MVP on 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
}

Posted in Exchange 2007, Powershell | Leave a Comment »

Send-MailMessage – Exchange 2007 sp2 and Exchange 2010

Posted by Krishna - MVP on 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

Posted in Exchange 2007, Powershell | 5 Comments »

Powershell to Get all the Exchange Services Status

Posted by Krishna - MVP on 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
}

Posted in Exchange 2007, Powershell | Leave a Comment »

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

Posted by Krishna - MVP on 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

Posted in Exchange 2007, Powershell | Leave a Comment »

Powershell to formally disable user accounts who have left Orginization

Posted by Krishna - MVP on 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

Posted in Active Directory, Exchange 2007, Powershell | Tagged: | Leave a Comment »

Powershell to Hide from GAL on all Disabled Mailbox

Posted by Krishna - MVP on November 11, 2009

Normally when ever user leaves orginization his account will be disabled and Hidden from GAL. Some times chances that users are just disabled and not hidden from GAL. Where is the script which pulls out all the mailbox which are in Accountdisabled state and it hides the account from the GAL

Get-Mailbox -ResultSize unlimited |Where{($_.UserAccountControl -like “AccountDisabled*”)} | set-mailbox -HiddenFromAddressListsEnabled $true

Posted in Exchange 2007, Powershell | Tagged: | Leave a Comment »

Active Directory SysVol Replication Migration from FRS to DFSR in windows 2008

Posted by Krishna - MVP on November 6, 2009

DFS Resplication service is only supported in Windows 2008 Domain Functional Level. If Active Directory is running in windows 2000 or windows 2003 then FRS is used to replicate Sysvole. If Domain Funcation is 2008 the all the domain controller in the domain must be windows 20080

There lots of advantages in using DFS Replication over FRS to replicate SysVolume. Below link has details description on the DFSR Migration and advantages list over FRS

http://blogs.technet.com/filecab/archive/2008/02/08/sysvol-migration-series-part-1-introduction-to-the-sysvol-migration-process.aspx

http://blogs.technet.com/filecab/archive/2008/02/14/sysvol-migration-series-part-2-dfsrmig-exe-the-sysvol-migration-tool.aspx

http://blogs.technet.com/filecab/archive/2008/03/05/sysvol-migration-series-part-3-migrating-to-the-prepared-state.aspx

http://blogs.technet.com/filecab/archive/2008/03/17/sysvol-migration-series-part-4-migrating-to-the-redirected-state.aspx

http://blogs.technet.com/filecab/archive/2008/03/19/sysvol-migration-series-part-5-migrating-to-the-eliminated-state.aspx

Posted in Active Directory, Windows 2008 | Tagged: , , | 1 Comment »

Windows Password Change Notification Script

Posted by Krishna - MVP on November 4, 2009

If your orginization has users who is working outside office network and they normally access email through pop3 then chances that they do not have any notification on password change. This script helps to intimate the give list of users to change the password.

Please find the copy of the script in the below link

http://powershell.com/cs/members/smtpport25.wordpress/files/PasswordChangeNotification.txt.aspx

 

Posted in Exchange 2007, VB Scripts, Windows 2008 | Tagged: , , , , , , | 4 Comments »

AD Powershell QuickReferrence

Posted by Krishna - MVP on November 4, 2009

There is beautiful Adpowershell Quick Reference quide in the below link

http://www.jonathanmedd.net/wp-content/uploads/2009/10/ADPowerShell_QuickReference.pdf

 

Posted in Active Directory, Powershell, Windows 2008 R2 | Tagged: | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.

Join 49 other followers