Monday 20 October 2014

Exchange 2007 SCR step by Step Implementation and Migration.....

Basic Requirements to Configure SCR:


1.    Server’s role like HUB/CAS/MAILBOX should be available into DR site as same like Production Environment.

2.    DR Database paths must be the same as like Production environment 

Ex:  If source   server is E:\Ex01\DB1 and E:\Ex01\Logs then these paths must be available on the target server.

3.    There should be only 1 database per storage group

4.    The target server must have Exchange mailbox role installed, if this is a cluster it will be install as a passive node.

5.    The target server must be in the same Active Directory Forest

6.    Active Directory site should be different based on location

7.    AD Site connector should be created between two sites

8.    Make sure that outgoing mail relay needs to be configured into DR site

9.    N/W Bandwidth should be considered as per requirement, minimum 2-4MB speed

10. Maximum 4 server can be configured for replication

 
Steps to Implement SCR:

1.    Run the below command on the target server (DR server).

Command: Enable-Storagegroupcopy sourceserver\Storage group -        StandbyMachine TargetServer -ReplayLagTime 0:0:0

Note: If the database size is large then you will not be able to create folders on DR servers across WAN link

2.    Always run Get-storagegroupcopystatus command to confirm replication status. Note: Result will be failed or suspended sometime, so no need to worry

Command:  Get-storagegroupcopystatus sourceserver\SSG –StandbyMachine  TargetMachine


Microsoft Exchange Server 2007 seeding is using the following three methods:



·         Automatic seeding: An automatic seed produces a copy of a storage group's database on the target. Automatic seeding requires that log1 be available on the source. Automatic seeding only occurs during the creation of a new server, creation of a new storage group and database, or on a database that has never been backed up.

·         You can use the Update-StorageGroupCopy command in the Exchange Management Shell to seed a storage group copy.

·         Manually copying the offline database, this process dismounts the database and copies the database file to the same location on the passive node. If you use this method, there will be an interruption in service because the procedure requires you to dismount the database.

·         Automatic seeding is not required to run Update-StorageGroupCopy. It will automatically create all data and log file.


             If it’s not happening then use the below second method:


3.    Suspend-StorageGroupCopy sourceserver\Storagegroup -StandbyMachine Target Sever

Click yes to suspend

     4.    Update-StorageGroupCopy EX01\SG01 -StandbyMachine DREX01

(Once above command run, you will see the progress of data copy. So wait for some time approx. 24 GB across 2 mbps link will take 3 to 4 days. if you are happy with this go for manually offline data copy which is not recommended because services will be stopped for that particular domain

After above steps is complete successfully, you will be able to see the database folder created into DR mailbox server.


5.    Resume-StorageGroupCopy EX01\SG01 -StandbyMachine DREX01

(After this you will be able to see the log folder into DR mailbox server

Run - Get-storagegroupcopystatus sourceserver\SSG –StandbyMachine    TargetMachine to check the status)

 
Steps to migrate database from Source to Destination in SCR Environment:

1.    Create new storage group into DR site with database then delete contains of the folder after dismounting database from DR exchange server.

2.    Dismount production storage group where SCR replication enabled.

3.    Below command will make the available of Data to mount into DR server

Command: Restore-Storagegroupcopy SourceServer\Storagegroup\database -StandbyMachine TargetServer
4.    Run eseutil /mh to check database status on the DR server

5.    If you found the SCR Database is in Dirty Shutdown then Run soft recovery
Command: eseutil /r e02 (e02 - This details you will file on the storage properties)

6.    Again run eseutil /mh to check status and you will find clean shutdown. In case issue is not fixed and able see error message run again following command to the hard recovery:

ESEUTIL /R E02 (Zero Zero or whatever the logs file leads with) /l     D:\SCR\SG2\Logs /S D:\SCR\SG2\Data (Ex - logs and database location)


ESEUTIL /R E02 (Zero Zero or whatever the logs file leads with) /l D:\SCR\SG2\Logs /S D:\SCR\SG2\Data /a  


Check again status using ESEUTIL /MH

7.    Use move-storagegrouppath

Command: Set-Mailboxdatabase SCRTARGET\RECOVER\RECOVERDB -AllowFileRestore:$true
8.    Then mount DR server storage group Run the below command

Get-Mailbox -Database hub-cas\SSG\MBX-SSG |where {$_.objectClass -NotMatch '(SystemAttendantMailbox |ExOleDBSystemMailbox)'}| Move-Mailbox -ConfigurationOnly -TargetDatabase DRE2K7\DRSSG\DRMBX -Confirm:$false

OR

You can directly open EMC console, right click on DR database and enabled Allow File restore as TRUE and mount the database.

 
Increase Database Size for register Key due to Exchange Standard Limitation:




 

 
 
 


         


 

Monday 25 August 2014

Office 365 PowerShell Commands Administration...


Load PowerShell Commands

To connect to Office365 via PowerShell:

 $Cred = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $Cred -Authentication Basic –AllowRedirection

Import-PSSession $Session

Import-Module MSOnline

Connect-MsolService –Credential $Cred

 ------------------------------------------------------------------------------------------------------

Disconnect PowerShell Session

Remove-PSSession $Session

[Alternative] rsn $Session

-------------------------------------------------------------------------------------------------------------------

Configure Mailbox Permissions

 To view Mailbox Permissions:

Get-MailboxPermission –Identity <MailboxID>

To Add Mailbox Permissions (Full Access):

Add-MailboxPermission -Identity <Mailbox ID 1> -User <Mailbox ID 2> -AccessRights  FullAccess -InheritanceType All

In this command line, <Mailbox ID 1> represents the target mailbox; <Mailbox ID 2> is the user who will be granted Full Access permission.

If an administrator wants to grant a user access to a room mailbox, the administrator may want to specify that user as the Owner. To do this, use the following command line:

Add-MailboxPermission -Identity <Mailbox ID 1> -Owner <Mailbox ID 2>

Note Only users who have Exchange mailboxes can be granted access to other mailboxes. Users who do not have mailboxes receive a permissions error when they try to access the other mailboxes.

To verify that the permissions are applied to Mailbox ID 1, use the following command:

Get-MailboxPermission -Identity <Mailbox ID 1> | Select User, AccessRights, Deny

Get-MailboxPermission -Identity “charterdg” | Select User, AccessRights, Deny

In the results, you should be able to confirm that <Mailbox ID 2> has been granted Full Access permission.

To remove the Full Access configuration on a mailbox, use the following command:

Remove-MailboxPermission -Identity <Mailbox ID 1> -User <Mailbox ID 2> -AccessRights FullAccess

-------------------------------------------------------------------------------------------------------


To grant Receive As access, use the steps that are described in the Grant full mailbox access section. Granting full mailbox access in Office 365 Exchange Online covers both the same permissions that are required for Receive As access.

-------------------------------------------------------------------------------------------------------


To view Send as Permissions:

Get-RecipientPermission -Identity <Mailbox ID 1>

To use PowerShell to configure a mailbox so that a user other than the mailbox owner can use that mailbox to send messages, use the following command:

Add-RecipientPermission -Identity <Mailbox ID 1> -Trustee <Mailbox ID 2> -AccessRights SendAs

In this command line, <Mailbox ID 1> represents the target contact/mailbox/distribution group; <Mailbox ID 2> is the user who you want to grant Send As permission.

To verify that the permissions are applied to Mailbox ID 1, using the following command:

Get-RecipientPermission -Identity <Mailbox ID 1> | Select Trustee, AccessControlType, AccessRights

In the results, you should be able to confirm that <Mailbox ID 2> has been granted Send As permission.

Note These permissions can be assigned to a user mailbox or Active Directory group objects.

To remove Send As settings from a mailbox, use the following command:

Remove-RecipientPermission -Identity <Mailbox ID 1> -AccessRights SendAs -Trustee <Mailbox ID 2>

-------------------------------------------------------------------------------------------------------

 

Configure "Send on behalf" permissions

To use PowerShell to grant a user the ability to send mail on behalf of another user, use the following command:

Set-Mailbox -Identity <Mailbox ID 1> -GrantSendOnBehalfTo <Mailbox ID 2>

Set-Mailbox -Identity mservices -GrantSendOnBehalfTo mservicesdg

Set-Mailbox -Identity support -GrantSendOnBehalfTo supportdg

In this command line, <Mailbox ID 1> represents the mailbox that you want to grant permissions to and <Mailbox ID 2> is the mailbox of the user who you want to grant access.

To verify that the permissions are applied to Mailbox ID 1, use the following command:

Get-Mailbox -Identity <Mailbox ID 1> | Select GrantSendOnBehalfTo

In the results, you should be able to confirm that <Mailbox ID 2> has been granted Send On Behalf permission.

Note These permissions can be assigned to a user mailbox or mail-enabled Active Directory security group objects.

To remove Send On Behalf permission from a mailbox, use the following command:

Set-Mailbox -Identity <Mailbox ID 1> -GrantSendOnBehalfTo $NULL

------------------------------------------------------------------------------------------------------ 

Calendar Permissions

To view permissions:

Add-mailboxpermission –identity <MailboxID:\calendar>

 Note: do not use the @domain for this first MailboxID

 Add-mailboxpermission –identity <MailboxID:\calendar> -user <MailboxID2> -AccessRights< attribute>

 Note: Most used attributes are Owner, Editor, Publishing Editor, Reviewer

 To Change Permissions:

Set-mailboxpermission –identity <MailboxID:\calendar> -user <MailboxID2> -AccessRights< attribute>

 

To Remove Permissions:

Remove-mailboxpermission –identity <MailboxID:\calendar> -user <MailboxID2> -AccessRights< attribute>

-------------------------------------------------------------------------------------------------------

 

Configure email forwarding

To configure mail forwarding for a mailbox by using PowerShell, use the following command:

Set-Mailbox -Identity "<Mailbox ID>" -ForwardingSmtpAddress "<Target SMTP Address>"

In this command line, <Target SMTP Address> can be either internal or external to Exchange Online.

Additionally, IT Gens should use the -DeliverToMailboxAndForward parameter to save a copy of the message to the local mailbox before the message is forwarded to another SMTP address. The following is an example:

Set-Mailbox -Identity "<Mailbox ID>" -ForwardingSmtpAddress "<Target SMTP Address>" –DeliverToMailboxAndForward $true

To verify that the permissions are applied to Mailbox ID 1, use the following command:

Get-Mailbox -Identity <Mailbox ID 1> | Select ForwardingSmtpAddress

To remove email forwarding that is configured on a mailbox, use the following command:

Set-Mailbox -Identity "<Mailbox ID>" -ForwardingSmtpAddress $NULL

-------------------------------------------------------------------------------------------------------


Set-MailboxRegionalConfiguration -Identity <mailboxID> -Language en-us -Timezone "Eastern Standard Time"

-------------------------------------------------------------------------------------------------------


get-user |export-csv  c:\users\extoluserlist.csv




Create new conference room:

New-Mailbox -Name "Test Room Mailbox" -Alias rm2 –Room

 Ex: New-Mailbox -Name "Conference Room - 1st floor - Lobby" -Alias "lobby_conf" –Room

-------------------------------------------------------------------------------------------------


Add-MailboxPermission -Identity <Mailbox ID 1> -Owner <Mailbox ID 2>

Ex: Add-MailboxPermission -Identity lobby_conf@XYZ.COM -Owner lconrads@XYZ.COM

 ------------------------------------------------------------------------------------------------

Change the Office 365 user Principle Name in Bulk

Script:

-------------------------------------------

$csv = import-csv "C:\temp\UPN.csv"

$csv  | Foreach {

$UserPrincipalName = $_.UserID

$NewUserPrincipalName = $_.newuserID

Set-MsolUserPrincipalName -UserPrincipalName $_.UserID -NewUserPrincipalName $_.newuserID

}

----------------------------------------------

.CSV format:

UserID,NewuserID

POC.Abc114@xyz.com,POC.Abc114@xyz.onmicrosoft.com

-------------------------------------------------------------------------------------------------

DIRECTORY SYNC command to get sync On-Premises AD to O365 Azure AD.

 Open a PowerShell command with Administration credential and run the below two commands:

 add-pssnapin Coexistence-Configuration
Start-OnlineCoexistenceSync


-------------------------------------------------------------------------------------------------



---------------------------------------------

$csv = Import-Csv “C:\temp\Contacts.csv”

foreach($line in $csv)

{

New-MailContact -Name $line.DisplayName -ExternalEmailAddress $line.EmailAddress -Alias $line.Alias

}

-----------------------------------------

.CSV format:

DisplayName,EmailAddress,Alias

Test.siemens(Lotus),Test.siemens@abc.com,Test.siemens

 

Deletion:

-----------------------------------------

$csv = Import-Csv “C:\temp\Remove-Contacts\Contacts.csv”

foreach($line in $csv)

{

Remove-MailContact -Identity $line.Alias -confirm:$false

}

-----------------------------------------

 .CSV format:

Alias

Test.siemens

Test.siemens1

Test.siemens2

-------------------------------------------------------------------------------------------------


 

Note: AD Quest PowerShell already installed in AD (PLSIE-DC2)

 

Get-QADUser -OrganizationalUnit "cg.corp/Service Accounts/O365" | ft FirstName,LastName,name,primarySMTPaddress,Initials

 ---------------------------------------------------------------------------------------

Set Password to Not Expire:
To set password never to expire for only one user please run below commands:
        Set-MsolUser -UserPrincipalName <Microsoft Online Services ID> -PasswordNeverExpires $true
        Get-MSOLUser -UserPrincipalName <Microsoft Online Services ID> | Select PasswordNeverExpires (verify if it was successful)
---Example---
Set-MsolUser -UserPrincipalName john@contoso.onmicrosoft.com -PasswordNeverExpires $true
To set password never to expire for all users please run below commands:
Get-MSOLUser | Set-MsolUser -PasswordNeverExpires $true
 
(To verify if it was successful)
 Get-MSOLUser | Select UserPrincipalName, PasswordNeverExpires
-------------------------------------------------------------------------------------------------
CHANGE USER PRINCIPLE NAME
To update a non-federated user's UPN while they have a license, follow these steps:
 
Connect to Microsoft Online Services by using the Microsoft Online Services Module for Windows PowerShell
Run the following PowerShell cmdlet:
Set-MsolUserPrincipalName -UserPrincipalName [CurrentUPN] -NewUserPrincipalName [NewUPN]
 ---------------------------------------------------------------------------------------------------
 
Thank You...
Avishek