Archive for category Poweshell

Azure resource re-allocation and Resource Groups

Azure-logoInfrastcuture in the cloud (IaaS) is such an evolving topic from the architectual point of view. As services do evolve and more functionalities get added in order to enable the end user to untilise these services in best forms, complexities do start to add to it.

IaaS require a lot of initial planning to minimise any downtime required to re-allocate services/servers for production (Prod).

If breaking to Azure services started as a proof of concept (PoC) initially and changed suddenly to being the business critical service that your business can’t function without – without the necessary transitional planning then we are on the same page here.

Microsoft Azure does add a lot of value to the business and continuity of its business operations.

In this article I will go over Azure different resources and the way they could be organised for ease of management and billing. Billing is an important topic if you want to understand how your services are being utilised in the cloud or in order to bill each business unit if your business is using the charge back model.

If you have just started building your infrastructure on Azure, ensure your business units use Azure Resource Groups to group their services/servers and that could save you a lot of time in the long run.

The way to move resources between different resource groups are a complex ‘PowerShell driven process’. First you need to understand the limitiation of resource move:

  1. vNet’s can’t be moved
  2. Re-allocated Azure resources will retain their source region, even if your destination resource group is in a different region.
  3. You can’t move a single VM attached to a cloud service, the cloud service and all VM’s attached to it will have to move together.
  4. From experience, move storage accounts seperately. When I try to move a storage account with the rest of resources I get error (“One resource move request can contain resources of only 1 provider.”) :storage-err
  5. If you would like to migrate the VM to a new vNet then the VM needs to be deleted and reprovisioned on the vNet – the VM will down for that duration.
  6. If you would like to move the VM to a new storage account, then the downtime will be much greater depending how big the VHD files are and the region. I won’t talk much about this process, you will find it detailed here.

Now we will talk about the interesting part, the move and re-allocation process.

  1. Download the latest Azure Powershell module (We will be using the latest Azure Resource Management module) as illustrated here
  2. Login to your subscription using Login-AzureRmAccount
  3. Get the content of your source resource group on Azure: Get-AzureRmResource
  4. Feed the output to Move-AzureRmResource

I have written a short script to demonstrate this process (MS Azure Resource Group Management(MS Azure Resource Group Management), I have added comments necessary to each of the steps in the script so you should be able to customize it to your needs.

,

Leave a comment

Couldn’t open backup file handle while performing Exchange DB seed via Powershell

Image

The error above is the outcome of running Udate-MailboxDatabaseCopyStatus -Identity DB_NAME -DeleteExistingFiles and the DB status went to Failed and Suspended. The reason is that the backup was kicked off and the handle for the DB was no longer available.

You could check the status of the backup on the DB by running Get-MailboxDatabaseCopyStatus -Identity DB_NAME | fl *backup*

DB-BK

 

Two ways to get over this, either to wait for the backup to finish or to reboot the server and stop the backup and that should fix the issue, the seeding process needs to start from scratch.

, ,

1 Comment

Soft Deleted Mailbox in Exchange 2010 (Continued)

In my previous post I have talked about what happens behind the scenes when you disconnect a mailbox via EMC. Soft deleted mailboxes stay on the system for the whole retention period (by default 30 days) hence they still utilise space within Exchange DB, if you are running on low disk space then this might become an issue.

Luckily there is a solution to this issue, using Remove-StoreMailbox command in Powershell, follow the solution in this MS article http://technet.microsoft.com/en-us/library/gg181092(v=exchg.141).aspx

,

Leave a comment

Soft Deleted Mailbox in Exchange 2010

Have you ever wondered why there are so many disconnected mailboxes? That has flagged a big security alert in our firm, especially after finding out how IT staff used to disable user accounts! By disabling a mailbox, you are actually detaching that mailbox form it’s AD object, this orphaned mailbox is prone to deletion according to your Exchange mailbox retention policy (by default 30 days!).

We have also found few other mailboxes for active users but they are sitting in Disconnected Mailbox, by running the command:

Get-MailboxStatistics -Server ServerName | where {$_.DisconnectReason -eq ‘SoftDeleted’}

The result would show user display name for those mailboxes that had moved from one DB to another. Exchange would mark the source mailbox as SoftDeleted rather than the default Disabled – a mailbox gets flagged as Disabled when disabling mailboxes using the Disable command within the MS Exchange GUI or Disable-Mailbox via Powershell.

,

1 Comment

Offline seed of Exchange 2010 DB in DAG environment

imagesAdding a member server to the DAG is an easy and worthy process, as it could provide protection against server failures and for remote sites it could save on bandwidth in regard to RPC (Outlook client) traffic to mail server.

In our situation, we have a stretched cluster which extends the DAG over a microwave link. copying a database over that link could take days, or weeks especially if we are talking about several databases with over 300 GB in size. This article will take you over offline seeding, this process proved successful in our case and very effective, but in order to get a successful result each of the steps outlined below have to be covered in that order.

Steps to offline seed Exchange 2010 DB

1. Before you even start, you should stop backing up the databases. Backups could truncate your logs files and cause the database to fail at the other end if any of the logs are missing.

2. Using DISKSHADOW.EXE tool, this tool is part of Windows 2008/2008 R2. With this tool we will be able to create a read only copy of the database volume before copying it to an external or network media.

3. At the command prompt, type DISKSHADOW.EXE

4. You can query available disk shadows by running: list shadows all

5. Set the snapshot as crash consistent type : Set Context Persistent

6. Add your volume ready for a snapshot (in our case the K drive): add volume K: alias kdrive

8. To create the VSS snapshot type: create

9. To expose the snapshot as a read only, type: expose %kdrive% Z:

10. Now at that point you should be able to see a Z drive available, it will give you a read only access which allows you to copy the content to a USB drive or directly to the target if the bandwidth permits. In our case we shipped it on a USB drive to our other remote site where we loaded it onto a temp drive on the target Exchange server. After copying the database, you can remove the volume and snapshot by running the following command using the Diskshadow.exe utility:

unexpose Z:

delete shadows volume K:

11. At this point we can create another database copy by running this Exchange PS command: (Make sure to use the -seedingpostponed key)

Add-MailboxDatabaseCopy -Identity DatabaseName -MailboxServer TargetExchangeServerName –SeedingPostponed

12. Place the database .db file in its corresponding directory

13. Then run PS:  Resume-MailboxDatabaseCopy “DatabaseName\TargetExchangeServerName

Now Exchange would validate the database and copy the required and missing log files form the source Exchange server.

, ,

12 Comments

Dynamic Distribution Group – Excluding Security Group

Exc_PS

It has been a while since I have posted anything on my blog, due to change of responsibilities and the new job. Now I am mainly focused on VMware and Exchange.

Most people know that Dynamic Distribution Groups are great in offering flexible and automatic management of user membership in addition to all the features offered by normal distribution groups. By the way, I won’t be detailing how to use Set-DynamicDistributionGroup cmdlet in setting a dynamic group up (please refer to powershell help by typing help Set-DynamicDistributionGroup -Examples to see some examples of how to use -RecipientFilter property).

If you image that you have all your users in one OU (which is possible) , Dynamic Distribution Group look at a specific recipient container. In some cases you want to exclude a single user from the list, now that is easy, make sure (-not(Name -like ‘name‘) is entered into your recipient filter.

Excluding one name is easy, but you don’t want to keep adding a name at a time. You could bind all of your members who you want to exclude from your dynamic group in a security group and add this line to your recipient filter (-not(MemberofGroup -eq ‘Security_Group_FQDN‘)).

Whoever is added to that Security group won’t be a member of the dynamic distribution group.

To get members of a dynamic distribution group

$group = get-DynamicDistributionGroup “Group_Name

$members = get-recipient -RecipientPreviewFilter $group.RecipientFilter

 

,

Leave a comment

Practical Powershell

Practical Powershell

I have been trying to link the information I get from VMware vSphere and the Compellent SAN to be able to trace VM activity within the storage layer end. I found a good post on the above link which gives a good link between the two systems using Powershell.

, ,

Leave a comment