• Bulk populate an AD using a CSV file and New-ADUser, including Passwords

    Problem : New-ADUser is not working as expected to populate a password coming from a CSV file (the account stays disabled) here is the example and the reason:

    Prerequisites: Import the Active Directory module on your powershell session using Import-Module ActiveDirectory

     

     

    Here is my BulkAddADUsers.csv file sample :

     

    GivenNAme,Surname,Name,SamAccountNAme,Description,Department,EmployeeID,Path,Enabled,Password,PasswordNeverExpires
    User,Test1,UserTest1,UserTest1,UserTest1,IT,189478,"OU=Test,DC=CONTOSO,DC=CA",$True,P@ssw0rd,$True
    User,Test2,UserTest2,UserTest2,UserTest2,IT,187516,"OU=Test,DC=CONTOSO,DC=CA",$True,P@ssw0rd,$True
    User,Test3,UserTest3,UserTest3,UserTest3,IT,134530,"OU=Test,DC=CONTOSO,DC=CA",$True,P@ssw0rd,$True
    User,Test4,UserTest4,UserTest4,UserTest4,IT,162455,"OU=Test,DC=CONTOSO,DC=CA",$True,P@ssw0rd,$True
    User,Test5,UserTest5,UserTest5,UserTest5,IT,121901,"OU=Test,DC=CONTOSO,DC=CA",$True,P@ssw0rd,$True
    User,Test6,UserTest6,UserTest6,UserTest6,IT,170221,"OU=Test,DC=CONTOSO,DC=CA",$True,P@ssw0rd,$True
    User,Test7,UserTest7,UserTest7,UserTest7,IT,128669,"OU=Test,DC=CONTOSO,DC=CA",$True,P@ssw0rd,$True
    User,Test8,UserTest8,UserTest8,UserTest8,IT,108705,"OU=Test,DC=CONTOSO,DC=CA",$True,P@ssw0rd,$True
    User,Test9,UserTest9,UserTest9,UserTest9,IT,106381,"OU=Test,DC=CONTOSO,DC=CA",$True,P@ssw0rd,$True
    User,Test10,UserTest10,UserTest10,UserTest10,IT,193922,"OU=Test,DC=CONTOSO,DC=CA",$True,P@ssw0rd,$True
    User,Test11,UserTest11,UserTest11,UserTest11,IT,174066,"OU=Test,DC=CONTOSO,DC=CA",$True,P@ssw0rd,$True
    User,Test12,UserTest12,UserTest12,UserTest12,IT,105871,"OU=Test,DC=CONTOSO,DC=CA",$True,P@ssw0rd,$True
    User,Test13,UserTest13,UserTest13,UserTest13,IT,126670,"OU=Test,DC=CONTOSO,DC=CA",$True,P@ssw0rd,$True
    User,Test14,UserTest14,UserTest14,UserTest14,IT,124671,"OU=Test,DC=CONTOSO,DC=CA",$True,P@ssw0rd,$True
    User,Test15,UserTest15,UserTest15,UserTest15,IT,118935,"OU=Test,DC=CONTOSO,DC=CA",$True,P@ssw0rd,$True
    User,Test16,UserTest16,UserTest16,UserTest16,IT,183367,"OU=Test,DC=CONTOSO,DC=CA",$True,P@ssw0rd,$True
    User,Test17,UserTest17,UserTest17,UserTest17,IT,185662,"OU=Test,DC=CONTOSO,DC=CA",$True,P@ssw0rd,$True
    User,Test18,UserTest18,UserTest18,UserTest18,IT,118972,"OU=Test,DC=CONTOSO,DC=CA",$True,P@ssw0rd,$True
    User,Test19,UserTest19,UserTest19,UserTest19,IT,187421,"OU=Test,DC=CONTOSO,DC=CA",$True,P@ssw0rd,$True
    User,Test20,UserTest20,UserTest20,UserTest20,IT,167020,"OU=Test,DC=CONTOSO,DC=CA",$True,P@ssw0rd,$True

     The following command will create the users with the attributes defined above, but since the Password is not encrypted, the account will be deactivated.

    [PS] C:\users\Administrator.DOMAINA\Desktop>import-CSV .\BulkAddADUsers.csv|New-ADUser

     

    image

     

    Note the AD accounts are not enabled, because the password was not taken from the CSV file, as New-ADUser requires a Secure String for the Password. Here is what you get when you try to enable it :

    image ==> image

     

     

    Solution : Type a longer command line using all New-ADUser properties + the ConvertTo-SecureString commandlet

    [PS] C:\users\Administrator.DOMAINA\Desktop>import-csv .\BulkAddADUsers.csv | % {New-ADUser -GivenName $_.GivenName -Surname $_.Surname -Name $_.Name -SamAccountName $_.SamAccountName -Description $_.Description -Department $_.Department -EmployeeID $_.EmployeeID -Path $_.Path -Enabled $True -AccountPassword (ConvertTo-SecureString $_.Password -AsPlainText -force) -PasswordNeverExpires $True}

     

    image

     

    Quod erat demonstrandum.

    Sam

  • Exchange 2003 to Exchange 2010 Intra-Organization migration

    Exchange 2003 to Exchange 2010 migration path

    Step

    Step Title

    Details (migration from Exchange 2003)

    Step 1

    Certificate

    Acquire new commercial certificate for external client coexistence with CAS 2010 (legacy.contoso.ca namespace required for former CAS2007 for silent redirect).
    It will neet at minimum 3 SAN values :
    - mail.contoso.ca (primary OWA/EAS/OA URL)
    - autodiscover.contoso.ca
    - legacy.contoso.ca (OWA/EAS legacy mailbox access)

    Subject name should be mail.contoso.ca, should match the "Certificate Principal Name" in Outlook profile for Outlook Anywhere

    Step 2

    Service pack level and AD version

    Use ExPDA (http://www.microsoft.com/downloads/en/details.aspx?FamilyID=88B304E7-9912-4CB0-8EAD-7479DAB1ABF2) to :
    a- Ensure all Exchange 2003 servers are SP2
    b- Ensure all Forest/Domain match Exchange 2010 prerequisites
    Note : One of the prerequisites is the link state minor changes suppression. The procedure to deactivate it is on Step 8.1

    Step 3

    Prepare AD

    Step 3.1.1

    1

    Preparing Legacy Exchange Permissions (Exchange 2003 coexistence only)

    1.1

    Setup /PrepareLegacyExchangePermissions

    1.2

    Wait AD changes to replicate-track the progress using REPLMON tool

    Step 3.1.2

    2

    Preparing schema

    2.1

    Run on a DC in schema master domain (forest root domain)
    Memberships required: Schema Admins group & Enterprise Admins

    2.2

    Setup /PrepareSchema (Schema Admins group + Enterprise Admins)

    2.3

    Wait AD changes to replicate-track the progress using REPLMON tool

    Step 3.1.3

    3

    Preparing AD

    3.1

    Run on a DC in schema master domain (forest root domain)
    Memberships required: Enterprise Admins

    3.2

    Setup /PrepareAD (Enterprise Admins)

    3.3

    Wait AD changes to replicate-track the progress using REPLMON tool

    Step 3.1.4

    4

    Preparing All Domains

    4.1

    Setup /PrepareAllDomains or setup /pad (Enterprise Admins)

    4.2

    Verify the AD changes

    Step 3.1.5

    5

    Repeatable Task:Preparing Domains (If Preparing All Domains not run-See notes)

    5.1

    If Preparing All Domains task was run, skip this task

    5.2

    Memberships required:
    If domain created BEFORE prepareAD: Domain Admins
    If domain created AFTER prepareAD: Domain Admins & Exchange Organization Administrators

    5.3

    Setup /PrepareDomain (see notes)

    5.4

    Verify the AD changes

    Step 4

    Install CAS2010

    Install CAS 2010 and configure it
    - specify the external namespace (e.g. mail.contoso.ca)
    - install RPC over HTTP proxy component
    - Configure OWA settings (FBA vs Basic auth)
    - Configure EAS authentication (Basic vs Certificate Auth)
    - Enable OA (Enable-OutlookAnywhere -Server:ServerName -ExternalHostName:mail.contoso.ca -SSLOffLoading $false)

    Step 4.1

    Configure CAS2010 ExternalURLS

    If the Step 4 above - enter the external namespace - has not been done, configure it on this step:
    •Offline Address Book: Set-OABVirtualDirectory \OAB* -ExternalURL https://mail.contoso.com/OAB
    •Web Services: Set-WebServicesVirtualDirectory \EWS* -ExternalURL https://mail.contoso.com/ews/exchange.asmx
    •ActiveSync: Set-ActiveSyncVirtualDirectory -Identity \Microsoft-Server-ActiveSync -ExternalURL https://mail.contoso.com/Microsoft-Server-ActiveSync

    Step 5

    Configure CAS2010 OWA

    Configure OWA on CAS2010 appropriately :
    - Outlook Web Access:
    . For environments with Exchange 2003 mailbox servers: Set-OWAVirtualDirectory \OWA* -ExternalURL https://mail.contoso.com/OWA -Exchange2003URL https://legacy.contoso.com/exchange
    - Exchange Control Panel :
    . Set-ECPVirtualDirectory \ECP* -ExternalURL https://mail.contoso.com/ECP

    Step 7

    Configure CAS2010 Array (LB + DNS + PowerShell)

    For Outlook clients, you can configure the CAS2010 servers as an RPC Client Access Service array, which is highly recommended even if you have only one CAS2010 you start with :
    - Create a LB array for CAS2010 (Step-by-step guide / installation template : http://technet.microsoft.com/en-us/library/cc742379(EXCHG.80).aspx)
    - Create a DNS entry in your INTERNAL DNS that resolves the LB Array name to the Virtual IP Address (VIP) of the CAS LB (e.g. CASArray01.Contoso.ca)
    - Configure the LB array to load-balance the MAPI RPC ports : TCP 135 and TCP 1024 - 65 535
    - Create the CAS Array AD object : New-ClientAccessArray -Name CASArray01.contoso.ca -FQDN CASArray01.contoso.ca -Site "Site1"

    Step 8

    Install HUB2010 and MBX2010

    Install the HUB2010 and MBX2010 roles in the "Internet Facing AD Site" and configure them:
    - You can change the OAB generation server and enable Web Distribution on CAS2010 :
    > Move the OAB : Move-OfflineAddressBook "Default Offline Address List" -Server Server_Name
    > add the CAS2010 server as a Web Distribution Point :
    ■$OABVDir=Get-OABVirtualDirectory -Server
    ■$OAB=Get-OfflineAddressBook "Default Offline Address List"
    ■$OAB.VirtualDirectories += $OABVdir.DistinguishedName
    ■Set-OfflineAddressBook "Default Offline Address List" -VirtualDirectories $OAB.VirtualDirectories

    Step 8.1

    Suppress Link State Updates on Exchange 2003

    HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\RESvc\Parameters
    1. Right-click Parameters and select New | DWORD value. Name the new DWORD value SuppressStateChanges.
    2. Double-click SuppressStateChanges.
    3. In the Value data field, enter 1.

    Step 9

    External DNS : create legacy.contoso.ca namespace

    Create the legacy host record (legacy.contoso.com) in your EXTERNAL DNS infrastructure and associate it either with the FE2003 infrastructure (less likely) or your proxy infrastructure (more likely).

    Step 10

    Environment without Exchange 2007 autodiscover

    You will configure EXTERNAL DNS and/or your reverse proxy infrastructure's publishing rules to have the autodiscover.contoso.com namespace point to CAS2010

    Step 11

    Publish legacy.contoso.ca to point to CAS2007 on reverse proxy

    If utilizing a reverse proxy infrastructure, you will publish the legacy namespace to the FE2003 infrastructure so that at this point the FE2003 infrastructure can be accessed either via mail.contoso.com or legacy.contoso.com namespaces

    Step 11.1

    Autodiscover setting to use NLB

    Set CAS property AutoDiscoverServiceInternalUri to the Load balanced FQDN :
    Get-ClientAccessServer | Set-ClientAccessServer -AutoDiscoverServiceInternalUri:"https://loadbalancerFQDN/Autodiscover/Autodiscover.xml"
    Get-AutodiscoverVirtualDirectory | set-AutodiscoverVirtualDirectory -InternalUrl:"https://loadbalancerFQDN/Autodiscover/Autodiscover.xml"

    Step 11.2

    Internet connectivity downtime (reconfigure 2003 FEs URLs to legacy.contoso.ca)

    Schedule the internet protocol client downtime (should be small enough time to make change and validate the configurations) during which we'll perform the following steps :
    - Reconfigure External DNS and/or your reverse proxy infrastructure's publishing rules to have the mail.contoso.com namespaces point to CAS2010.

    Step 11.3
    (Exchange 2003 EAS)

    Internet connectivity downtime (for Exchange 2003 EAS clients)

    Exchange 2003 mailboxes : EAS client will try to connect through CAS2010 and will receive an error.
    SOLUTION : enable Integrated Windows Authentication on the Microsoft-Server-ActiveSync vDir on Exchange 2003.

    > Install http://support.microsoft.com/?kbid=937031 and then use the Exchange System Manager to adjust the authentication settings of the ActiveSync virtual directory.
    > OR, set the msExchAuthenticationFlags attribute to a value of 6 on the Microsoft-Server-ActiveSync object within the configuration container on each Exchange 2003 mailbox server. An example script is provided at http://technet.microsoft.com/en-us/library/cc785437.aspx.
    Note: DO NOT use IIS Manager to change the authentication setting on the Microsoft-Server-ActiveSync virtual directory as the DS2MB process within the System Attendant will overwrite the settings that are stored in Active Directory.

    Step 11.4
    (OA)

    Internet connectivity downtime (disable Exchange 2007 OA)

    Disable Outlook Anywhere by utilizing the Exchange System Manager and selecting the "Not part of an Exchange managed RPC-HTTP topology" radial button on the RPC-HTTP tab of the Front-End server's properties.
    Optionally, you can also remove the RPC over HTTP proxy component (refer to your Windows Server documentation for more information).
    Important: This requires an up-front investment in CAS2010 architecture as all Outlook Anywhere clients will utilize CAS2010 once you transition the Outlook Anywhere endpoint. Be sure to follow all proper scalability planning documentation when deploying CAS2010 to ensure that you do not create a bottleneck in your CAS infrastructure due to Outlook Anywhere clients.

    Step 11.6
    (test)

    Test

    Test all client scenarios

    Step 12

    Production launch

    Complete downtime and enable Internet protocol client usage

    Step 13

    HUB

    Install the Hub Transport server role

    Step 14

    UM (optional)

    Install the Unified Messaging server role
    This step is optional. It's only necessary if you want to use Unified Messaging in your organization.

    Step 15

    UM Config (Optional)

    Configure Unified Messaging
    This step is optional. It's only necessary if you want to use Unified Messaging in your organization.

    Step 16

    MAILBOX

    Install the Mailbox server role

    Step 17

    EDGE (Optional)

    Install the Edge Transport server role
    This step is optional. It's only necessary if you want to use the Edge server role in your organization.

    Step 18

    Internet Mail Flow configuration

    Move Internet mail flow from Exchange 2003 to Exchange 2010 (DNS MX records changes and SMTP forwarder change - Ironport, ISS or whichever SMTP smarthost server is used in the perimeter network)

    Step 19

    Move Mailbox

    Move mailboxes from Exchange 2003 to Exchange 2010

    Step 20

    Move Public Folders

    Move public folder data from Exchange 2003 to Exchange 2010 (Use PF replicas on a 2010 server)

  • Active Directory Schema upgrade procedure - with back-out plan

     

    The aim of the procedure in this post is to avoid you to dig around the technet to rebuild it. It’s written for Exchange 2010 SP1 here, but can easily be adapted for any product schema updates by replacing the Exchange 2010 SP1 values and links !

     

    AD Schema upgrade procedure with verifications (can be adapted as a general procedure by changing the Exchange 2010 SP1 references and values)

    Perform Exchange server 2010 SP1 schema extension, the full procedure list is available online at http://technet.microsoft.com/en-us/library/bb125224.aspx :

    1. Confirmation that the “Back-Out Plan” (see below) has been prepared.

    2. Logon to the Domain Controller holding the Schema Master FSMO role using a credential that belongs to the Schema Admins security group and Enterprise Admins security group.

    3. Dump the current schema into a file for comparison.  From a command prompt, run the command:  Ldifde -f Before_Schema_Update.ldf -d "cn=schema,cn=configuration,dc=domain,dc=root"

     

    Important note : although the following step technically works, blocking AD replication by any means is not recommended, and not supported by Microsoft. As my colleague and AD expert Tanner Slayton comments (taking his words as these are complete and meaningful), Microsoft Best Practices are to test the upgrade in a Lab, ensure that a tested and well-documented Disaster Recovery plan is in place (e.g. including a detailed authoritative restore procedure of the AD to recover a previous good AD state in an unlikely case of corruption during the schema update), validate the schema extensions using Step 6. below for example, and ensure all DC's are healthy and replicating properly.

     

     

    <***update**** Unsupported and not recommended... test in a lab, document DR plan, rely on this DR plan in case of schema update issue **********>

    4. Ensure no replication from this Domain Controller is going to replicate to other server until Schema Extension is completed and verified:

    a. Disable Outbound Replication on the server

    i. At a command prompt, run the command: “repadmin /options +DISABLE_OUTBOUND_REPL” without the quotation marks.

    ii. Unplug the physical network connection to ensure no communication could occur with other domain controllers.

    <\***update**** Apart from the above "+disable_outbound_repl" steps and the below "-disable_outbound_repl" on Step 8., the remainder of the article remains well supported **********>

     

     

    5. At a command prompt, run the command “setup /PrepareSchema” from the folder where the Exchange 2007 SP3 installation files are located.

    6. If there is no error during the schema extension, then verify the current schema version. 

    a. Open ADSIEdit and check the Schema version located in:

       CN=ms-Exch-Schema-Version-Pt,CN=Schema,CN=Configuration,DC <root domain>

       Attribute: rangeUpper

       For Exchange server 2010 SP1, the value should be “14726

    b. In the same ADSIEdit session, check the ObjectVersion location in:

       CN=<your organization>, CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=<domain

       Attribute: ObjectVersion

       For Exchange server 2010 SP1, the value should be “13214

    c. Dump the current schema into a file and compare with the one obtained in step 3.  From a command prompt, run the command:  Ldifde -f After_Schema_Update.ldf -d "cn=schema,cn=configuration,dc=domain,dc=root"

    d. Compare the content in the file Before_Schema_Update.ldf and After_Schema_Update.ldf to ensure proper extension is completed.  For a list of schema changes applied by Exchange server 2010 SP1 is available online at http://msdn.microsoft.com/en-us/library/dd877014(EXCHG.140).aspx

    7. If the schema extension is unsuccessful or error was encountered during the extension, perform back out procedure for Schema Extension.

     

    <***update**** Unsupported and not recommended... test in a lab, document DR plan, rely on this DR plan in case of schema update issue **********>

    8. If schema extension is successful and verified

    a. re-enable Outbound Replication on the server

        i. At a command prompt, run the command: “repadmin /options -DISABLE_OUTBOUND_REPL” without the quotation marks.

        ii. Re-connect the network cable

    <\***update******* Apart from the "+disable_outbound_repl" steps on Step 4. and the above "-disable_outbound_repl" on Step 8., the remainder of the article remains well supported **********>

     

    9. Force replication of Active Directory

    10. Allow time for replication to be completed before execution of this step.  At a command prompt, run the command “setup /PrepareAD” from the folder where the Exchange 2010 SP1 installation files are located.

    11. For every domain that you have Exchange servers deployed and users having Exchange mailboxes, run the command “setup /PrepareDomain”.

     

     

    ***Update: The below back-out procedure takes into account the steps used to disable replication above, which are not supported and not recommended by Microsoft any more.

    Instead, the recommended Back-Out plan procedure is to have a well-documented and tested DR procedure including an authoritative restore procedure in case of AD corruption.

    Back-out plan Procedure (never had to use it but it’s a parachute/belt/mattress to sleep well)

    In case of incomplete schema extension or getting error during the schema extension, to avoid for any partial update of the schema to be replicated to other Domain Controllers, we must follow the steps below:

    1. Power off the current Domain Controller that we’re working with, i.e. the current Schema master.

    2. Go to another Domain Controller in the same domain, and seize the Schema Master FSMO role:

    a. Logon to the Domain Controller using a credential that has Enterprise Administrator privilege

    b. Click Start, click Run, type ntdsutil in the Open box, and then click OK.

    c. Type roles, and then press ENTER.

    d. Type connections, and then press ENTER.

    e. Type connect to server <servername>, and then press ENTER, where <servername> is the name of the domain controller that you want to assign the FSMO role to.

    f. At the server connections prompt, type q, and then press ENTER.

    g. Type seize Schema Master.

    h. At the fsmo maintenance prompt, type q, and then press ENTER to gain access to the ntdsutil prompt. Type q, and then press ENTER to quit the Ntdsutil utility.

    3. Perform meta data clean up to remove the domain controller we use for Schema Extension, this is to ensure non partial schema extension get replicated:

    a. Stay logon to the same server with the same credential as in step 2

    b. Click Start, click Run, type ntdsutil in the Open box, and then click OK.

    c. Type metadata cleanup, and then press ENTER.

    d. At the metadata cleanup prompt, type remove selected server <ServerName> where <ServerName> is the distinguished name of the domain controller whose metadata you want to remove, in the form of cn=ServerName,cn=Servers,cn=SiteName,cn=Sites,cn=Configuration,dc=ForestRootDomain

    e. To verify that the server was removed, type list servers in site, and then press ENTER. Ensure that the domain controller that you wanted to be removed is no longer displayed in the command output.

    f. At the metadata cleanup: and ntdsutil: prompts, type quit.

    Important:  If the domain controller that was removed was also a DNS server, ensure that references to it are removed from the Name Servers tab in the DNS console. To do this, open the DNS console using another DNS server in the domain (dnsmgmt.msc), and then click the domain name under Forward Lookup Zones. Remove any references to the domain controller that was removed from the domain.

    4. Clean up all DNS record related to the old Schema Master server

    5. Format the old Schema Master machine, reinstall Operating System, Reset computer account for the old server name, join back into the domain and prompt to Domain Controller and Global Catalog if that was its old configuration.

    Full documentation of how to clean up the Active Directory after an unsuccessful demotion of Domain Controllers, which is similar to the situation we have here, is available online at http://support.microsoft.com/kb/216498.

  • Exchange Server–Use ExTRA to take traces for search issues

     

    To diagnose a problem more indepth, we will use the Exchange Troubleshooting Analyzer (from the Toolbox on the Exchange Management Console) :

    - Select a task

    - Click on trace control

    - Click on set manual trace log

    - On components to trace, choose Store.

    - On trace tags, choose: tagQueryCi , tagQueryCiDump, and tagSearch

    - Click on start tracing

    - Then check the application log, once you see the event on the application log,

    stop tracing.

    - an MS Support Engineer will then analyze the *.etl resulting file

     

    MS Support will then use an internal debugging tool to decrypt or transform the resulting etl file to a readable format, and analyze it and eventually give you the analyzis results.

  • Exchange Server 2010 SP1–The replacer of PFDAVAdmin : ExFolders

     

    To manage your public folders permissions, including the system folders if you still use them with Outlook 2003 clients, you no longer use PFDAVAdmin, but use ExFolders in replacement.

    Some of the many new features that deserve to be underlined are :

    • This can be run from an Exchange 2010 server only
    • Can connect to Exchange 2010 or Exchange 2007 only, not Exchange 2003
    • You can export properties of public folders and also export properties of all objects in a public folder
    • Ability to connect to multiple mailbox stores at the same time to run bulk operations against multiple mailboxes across many databases at the same time

     

    All the details and the download link are here : http://gallery.technet.microsoft.com/Exchange-2010-SP1-ExFolders-e6bfd405