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


Powershell to Hide from GAL on all Disabled Mailbox

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


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

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


Windows Password Change Notification Script

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

 


AD Powershell QuickReferrence

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

 


Windows 2008 R2 Powershell AD Cmdlets

October 29, 2009

Widows 2008 R2 comes with powershell v2 by default. and added with 76 new Ad cmdlets and Ad provders

New-ADOrganizationalUnit -Name “OUname” -ProtectedFromAccidentalDeletion $true

This command creates new OU under the root. If we wanted created OU in specific path then we have to provide the pat. Below is the example of the same

New-ADOrganizationalUnit -Name “OUname” -Path “OU=AllUsers,dc=grayson,dc=test”  -ProtectedFromAccidentalDeletion $true

-ProtectedformAccidentDeletion $true help to protect the OU getting accidentially deleted.

Get-ADOrganizationalUnit

Helps to get the details of the required OU

Set-ADOrganizationalUnit

Helps to modify the OU

Remove-ADOrganizationalUnit

Helps to remove the required OU


Powershell to send email with delivery notification enabled

October 28, 2009

Powershell to send email with delivery notification enabled. Once mail is delivered to the recipient mailbox and delivery notification mail will be sent to the sender mailbox. Below powershell help you to atchive the same

$msg = new-object Net.Mail.MailMessage
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.Headers.Add(“Disposition-Notification-To”, “from@domainname.com”)
$msg.DeliveryNotificationOptions = “OnSuccess”
$msg.From = “from@domainname.com”
$msg.To.Add(”to@domainname.com”)
$msg.Subject = “Make the Delivery Recipt Work Please”
$msg.Body = “In a perfect world this email will generate a delivery receipt”
$msg.Attachments.Add($att)
$smtp.Send($msg)


Powershell to Settup ManagedFolderAssistantSchedule in all Exchange 2007 Mailbox Servers

October 15, 2009

The managed folder assistant is a Microsoft Exchange Mailbox Assistant that creates managed folders in users’ mailboxes and applies managed content settings to them. When the managed folder assistant is running, it processes all of the mailboxes on a server. If the managed folder assistant does not finish processing the mailboxes on the server during the time that you have scheduled, it automatically resumes processing where it left off the next time it runs. There is one managed folder assistant for each server

Get-ExchangeServer | Where { $_.AdminDisplayVersion.ToString().SubString(0, 10) -eq “Version 8.” `

-and $_.ServerRole -eq “Mailbox” } |

ForEach { Set-MailboxServer -Identity $_.Identity `

-ManagedFolderAssistantSchedule “Sun.1:00 AM-Sun.3:00 AM”, `

“Mon.1:00 AM-Mon.3:00 AM”, “Tue.1:00 AM-Tue.3:00 AM”, `

“Wed.1:00 AM-Wed.3:00 AM”, “Thu.1:00 AM-Thu.3:00 AM”, `

“Fri.1:00 AM-Fri.3:00 AM”, “Sat.1:00 AM-Sat.3:00 AM” }

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


LogParsing with Exchange SMTP Protocol Logs

October 14, 2009

SMTP Protocol logs are not enabled by default.  In Both Exchange 2003 and Exchange 2007 SMTP Protocol logs need to be manually enabled.

In Exchange 2003 SMTP protocol logging is enabled on the SMTP Virtual Servers

SMTPVirtualServer

Please download log parser from following link

http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&displaylang=en

Below log parser command help you to get list of servers connecting to Exchange 2003 server through SMTP

logparser “Select cs-username,count (*) as Hits from N:\ex0910.log GROUP BY cs-username ORDER BY Hits Desc” -o:DATAGRID

Below is the output it provides the list of server name and number of hits from that specific servers

Logparset

Below mentioned article describes on how to enabled smtp protocol logging on Exchange 2007 and log files path

http://smtpport25.wordpress.com/2009/10/

Below command helps you to get the list of servers connect to the exchange server for sending emails

logparser “select REVERSEDNS(EXTRACT_PREFIX(remote-endpoint,0,’:')) as RemoteSendingHost, count(*) as Hits from RECV*.log group by RemoteSending Host order by Hits DESC” -i:CSV -nSkipLines:4  -o:DATAGRID

related articles

http://msexchangeteam.com/archive/2007/09/12/446982.aspx
http://msexchangeteam.com/archive/2007/11/12/447515.aspx
http://msexchangeteam.com/archive/2007/11/28/447598.aspx
http://linuxlore.blogspot.com/2006/11/howto-use-microsofts-logparser-to.html


SMTP Protocol Logging In Exchange 2007

October 12, 2009

Exchange Protocol Logging is not Enabled by Default in Exchange 2007. We have to enable the logging if required. Below powershell commands help you to enable the

Set-SendConnector “Send Connector Name” -ProtocolLoggingLevel verbose
Set-ReceiveConnector “Connector Name” -ProtocolLoggingLevel verbose

You can also enable the connector through Exchange Management Console.

EMC -> Exchange Orginization -> Hub Transport Servers -> Send connectors (tab) -> Right click on the required connector properties -> select Verbose

SendConnector

Location of STMP Logs in the below mentioned location
\Exchange Server\TransportRoles\Logs\ProtocolLog\SmtpReceive
\Exchange Server\TransportRoles\Logs\ProtocolLog\SmtpSend