Thursday, 19 December 2013

Blog Move

Just letting you all know, I have recently moved my blogs across to my new blogging site - http://modalyitblog.wordpress.com/

Thursday, 12 December 2013

PowerShell - Disable AD Account & Enable Out Of Office Reply

PowerShell - Disable AD Account & Enable Out of Office

Here is a nice simple script that admins can run to disable a user account within AD, move the account to the "Disabled Users" OU with the user description stamped with the user account used to run the script and the time & date, set a standardised out of office reply (informing people they have left the company) and removes the user from the global address list in Exchange.

All that is needed is the AD username of the user you wish to disable.

Update - 14/12/2013.

I have added additional functionality to send an email confirmation to the manager of the account you are disabling and added additional informational comments. Extracts of the send mail function were used from http://blogs.msdn.com/b/rkramesh/archive/2012/03/16/sending-email-using-powershell-script.aspx.

# *************************************************************************
# ****** Disable Active Directory User Account & Set Out Of Office PowerShell Script   ******
# ******                                                                                                                 ******
# ****** Created by Maurice Daly on 12/12/2013                                                      ******
# ****** Follow me on Twitter - modaly_it                                                                ******
# ******                                                                                                                 ******
# ****** Updated on 14/12/2013                                                                              ******
# ****** Description updated to use active directory name instead of the username      ******
# ****** Email confirmation now sent to ex-employee's manager                                 ******
# ******                                                                                                                  ******
# ***************************************************************************


# Import Required PS Modules
cls
write-host "Importing Active Directory PS Commandlets"
Import-Module ActiveDirectory
write-host "Importing Exchange Server PS Commandlets"


# Connect to MS Exchange
write-host "Connecting to MS Exchange"
$ExchangeSMTP = "YOURSMTPSERVER"
$ExchangePowerShell = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri
http://YOUREXCHANGESERVER/Powershell
Import-PSSession $ExchangePowerShell

cls
write-host "Disable Active Directory User Account & Enable Out Of Office"
write-host ""


# Get Variables
$DisabledDate = Get-Date
$LeaveDate = Get-Date -Format "dddd dd MMMM yyyy"
$DisabledBy = Get-ADUser "$env:username" -properties Mail
$DisabledByEmail = $DisabledBy.Mail


# Prompt for AD Username
$Employee = read-host "Employee Username"
$EmployeeDetails = Get-ADUser $Employee -properties Mail,Manager
$Manager = Get-ADUser $EmployeeDetails.Manager -Properties Mail
$ManagerEmail = $Manager.Mail


cls
# Prompt for confirmation
write-host "******************** CONFIRM USER DISABLE REQUEST ***********************"
write-host ""
write-host -ForegroundColor Yellow "Please review the Employee details below to ensure you are disabling the correct user account."
Get-ADUser $Employee | fl
$UserDetails = Get-User $Employee

$choice = ""
 while ($choice -notmatch "[y|n]"){
     $choice = read-host "Do you want to continue? (Y/N)"
     }

# Actions
if ($choice -eq "y"){
        cls
        write-host "******************************** DISABLING USER ACCOUNT ********************************"
        write-host ""
        write-host "Step1. Modifying user description for audit purposes" -ForegroundColor Yellow
        Set-ADUser $Employee -Description "Disabled by $($DisabledBy.name) on $DisabledDate"
        write-host "Step2. Disabling $Employee Active Directory Account." -ForegroundColor Yellow
        Disable-ADAccount $Employee
        write-host "Step3. Moving $Employee to the Disabled User Accounts OU." -ForegroundColor Yellow
        write-host ""
        Get-ADUser $Employee | %{move-ADObject $_.DistinguishedName -targetpath 'OU=Disabled User Accounts,DC=YOURDOMAIN,DC=YOURDOMAIN'
        write-host "Waiting 15 seconds for AD & Exchange OU update to complete"
        sleep -Seconds 15
        write-host ""
        write-host "Refreshing Employee Details for Exchange Modification."
        write-host ""
        Get-ADUser $Employee -Properties Description | Format-List Name,Enabled,Description
        write-host "Step 4. Setting Exchange Out Of Office Auto-Responder." -ForegroundColor Yellow
        Set-MailboxAutoReplyConfiguration $Employee -AutoReplyState enabled -ExternalAudience all -InternalMessage "Please note that I no longer work for $($UserDetails.company) as of $LeaveDate." -ExternalMessage "Please note that I no longer work for $($UserDetails.company) as of $LeaveDate."
        write-host "Step 5. Removing $Employee from Exchange Global Address Book." -ForegroundColor Yellow
        Get-Mailbox -Identity $Employee | Set-mailbox -HiddenFromAddressListsEnabled $true
        Write-Host "Step 6. Sending Confirmation E-mail To Employee's Manager." -ForegroundColor Yellow
        $msg = new-object Net.Mail.MailMessage
        $smtp = new-object Net.Mail.SmtpClient($ExchangeSMTP)
        $msg.From = "$($DisabledBy.Mail)"
        $msg.To.Add("$($Manager.Mail)")
        $msg.subject = "IT Notification - Employee Leaver Confirmation"
        $msg.body = "This email is confirm that $($Userdetails.Name)'s account has been disabled. An out of office notification advising that $($Userdetails.Name) has left the company has also been set. Note that the account will be deleted after 30 days."
        $smtp.Send($msg)
                  
      
                }
     }
    
 else {
        write-host ""
        write-host "Employee disable request cancelled" -ForegroundColor Yellow}





Disclaimer - Use this script at your own risk, I accept no responsibility for any issues arising from it.
 


 

Saturday, 7 December 2013

Book Review - Hyper-V Replica Essentials

E-Book Review: Hyper-V Replica Essentials

Hyper-V Replica Essentials

Language : English
Release Date : October 2013
ISBN : 1782171886
ISBN 13 : 9781782171881
Author(s) :
Vangel Krstevski

URL : http://bit.ly/1aDezz9

I was recently asked to review a new publication for Packt Publishing which focuses purely on one of the most talked about features in Windows 2012 server - Hyper-V Replica.

Hyper-V Replica Essentials is one of the first publications to focus specifically on the Hyper-V replica role alone, which probably is a good thing given that for most businesses in the SME sector will be looking to make this feature part of their disaster recovery / business continuity plan.

The author Vangel Krstevski has produced this step by step guide (96 pages in total) with one aim, to provide you the reader with a basic understanding of the technologies covered and to provide a means to setup a highly available Hyper-V cluster with disaster recovery. The book commences with an overview of virtualisation and Microsoft’s real entry into the virtualisation game with Windows Server 2008 R2 before swiftly moving on to Windows Server 2012 Hyper-V Replica.

The Good Points

The author has opted to take the reader through the entire process of establishing a functional environment up with step by step screen shots of the installation procedures and provides basic architectural diagrams. Going down this route ensures that even junior administrators and server engineers who are unfamiliar with scripting everything through PowerShell can produce a basic deployment that in theory, just works.

I found the book to be structured well and easy to read, the inclusion of screenshots ensures that a visual reference point accompanies your build. Chapters 3 & 5 provide even the most sceptical admin/engineer who is more familiar with technologies from other vendors such as VMWare, that administration and failover processes are really that straight forward to test or implement. This provides piece of mind to those making or suggesting a switch in virtualisation platform.

Chapter 4 focuses on setting up the PKI requirements for securing replication which for those of you unfamiliar with certificates is particularly useful whilst the final chapter deals with administration of your clustered highly available, DR enabled environment. External reference links are also provided in the final chapter for those of you who wish to find out more in depth information.

Some Objective Criticism

As previously mentioned the author takes the route of using GUI based procedures for installing the various roles, this is good for the novice user however seasoned administrators are moving more and more towards PowerShell scripting their installations and I believe to omit these commands to be an oversight. One example would be the QOS bandwidth throttling in Hyper-V as this is handled purely through PS commands, vital for those who do not wish to find that their nice new feature has saturated their WAN links as soon as it goes into production.

One other key point missed within the book is around replication of the page file and the serious implications this can have on the Hyper-V replica logs (HRL files). Microsoft recommend that the page file is relocated to a separate VHD for this purpose as the VHD can then be excluded on the replication, however the page file disk must be excluded on the initial VM replication configuration and cannot be implemented retrospectively. http://social.technet.microsoft.com/wiki/contents/articles/12800.hyper-v-virtual-hard-disks-with-paging-files-should-be-excluded-from-replication.aspx

Last of all I believe more detail around NIC roles within Hyper-V and VLAN segregation should have been covered, even at a basic level. Without clear definition networking can be the downfall of any Hyper-V deployment, especially when it gets down to the storage layer.

Conclusion

Hyper-V Replica Essentials provides even novice users with a means to set up and provide their business with a business continuity solution through the free out of the box Hyper-V replica feature in Windows Server 2012.

At the time of writing I would suggest that at €16.14 for the electronic E-Book (which I opted for and found a joy to read on my iPad) provides excellent value for money, especially when you consider a basic Hyper-V training course would cost multiples of this amount. In fact why not use the difference to purchase some additional literature from Packt's extensive book list, for more info visit their website at http://www.packtpub.com.

Finally, I would personally like to see an updated version to cover the updated features of Hyper-V replica in Windows 2012 R2 and potentially address some of the points I have raised above.

Friday, 30 August 2013

Hyper-V Replica - Large HRL File Growth Caused By SCOM HealthService.exe

Windows 2012 Hyper-V Replica

Initial Thoughts & Highlights

Having recently migrated all of my virtual servers to new hardware / Windows 2012 cluster I was free to reload our legacy Windows 2008 R2 cluster with 2012 and enable the much talked about Hyper-V replica feature as our DR solution.

My first impressions on the new feature were obviously positive given the fact it is a "free" feature of the operating system and allows us to replicate between two different hardware platforms. My only criticism during the initial stage was the inability to modify the replication delta times and the path to which the initial replication takes place, but all were minor details and indeed the R2 release will bring the ability to change the replication time value in the not so distant future.

Following replication of half the server estate I went through the failover test process with no issues, providing much kudos to myself for delivering the solution to the business at a minimal cost. It also provided a better night sleep knowing that a SAN failure would be recoverable in a short period of time.

Replication Size Concerns

Having observed our replication figures for a 24 hour period I found that the average replication figures were greatly higher than anticipated, ranging from low MB's on some servers to high MB's on others. As a sanity check I reset the figures and continued to monitor the growth for another 24 hours, with the end result not being consistent values for both sets of 24 hour periods.

The greatest concern I had at this point was even virtual servers with minimal roles had growth of at least 8MB every 5 minutes, which when you consider I have a relatively small estate of 60 virtual servers it would equate to a replication requirement of 138GB's per 24 hour period.

(Growth Figure x Intervals Per Hour x Number of Hours x Number of Servers)

When I looked at these figures it became clear that replicating this volume of traffic over a WAN connection would have serious issues regardless of our local connectivity.

Something has to be wrong.

Diagnosing The Issue

Taking the 8MB figure I set out to determine why our less critical / work loaded servers exhibited this behaviour. Taking a look at my estate and I found an exception to the rule on a DMZ hosted server, so why was this machine behaving differently I thought. The answer was the server in question was not monitored by our Systems Center product suite as it was essentially retired.

Now I had a definite line of enquiry I set about disabling services to determine the issue, the end result was the SCOM Health Service (HealthService.exe) agent being determined as the culprit.

Issue Found

When the SCOM Agent is running it causes a HRL delta of 8192kb to occur every 5 minutes, disabling the service shows a clear reduction in the HRL file growth to the point that the HRL file does not grow for large periods when running tests with replication paused.

UPDATE - 17/10

After much logging MS Support have concluded that the IO generated by the SCOM edb database is causing the issue but this is by design. Looks like it is time to look at another replication package such as Veeam to replace Hyper-V replica for my environment as the overhead is too high. A real shame given the hype about Hyper-V replica.


Friday, 15 March 2013

Exchange Migration - Correcting IMAP folders

Following a legacy migration from an old email server I found that users had difficulty with particular folders that were migrated over displaying their correct contents in Outlook. If the user opened the folder in OWA they had no issue.

The cause of this behaviour is due to the folder type being set as an IMAP folder in Exchange. To correct this issue simply follow the below procedure (as always after making the required backups):

Download and Install ExFolders:
  1. Confirm you are running at least SP1 for Exchange 2010
  2. Download ExFolders for Exchange 2010 (SP1+) from http://gallery.technet.microsoft.com/Exchange-2010-SP1-ExFolders-e6bfd405
  3. Install the ExFolders utility by running the registry file contained within the ZIP and copying the ExFolders.exe file to the Exchange bin directory
Run the ExFolders utility:
  1. Run the ExFolders.exe file
  2. Click on File - Connect
  3. Connection Type should be set to Mailboxes and Connect by set to Database
  4. Click on the Select button next to the "Global Catalog" section. Enter a DC running the global catalog role
  5. Click on Select next to the "Database(s)" section and select the required exchange database
  6. Click OK, at this point you should see a list of mailboxes contained within the database(s) you selected from the previous step
  7. To run modifications for all mailboxes simply highlight the Mailboxes root, otherwise highlight the user mailbox you wish to update
  8. To enable logging for troubleshooting purposes click on Tools, Options and enable both the "Enable logging to file" and "Enable extended logging" then click OK
  9. Click on Tools - Custom Bulk Operation then paste in the following into the Overall Filter section : (&(0x3613001E=IPF.Imap))
  10. Now click on the Add button and on select "Other folder properties" on the Operation Type prompt
  11. Click on the Property drop down list and select "PR_CONTAINER_CLASS : 0x3613001E"
  12. Enter the following into the Value field : IPF.Note and click on the Add button
  13. Click OK and OK again
  14. The update process will now run, correcting all IPF.Imap folders contained within the selected Database / Mailbox to the standard IPF.Note format

Note that it can take a few minutes for Outlook to update the folder type information.

I hope this helps you out.

Thursday, 3 January 2013

System Center 2012 SP1 RTM

System Center 2012 SP1 has been officially hit RTM status and been released to Microsoft VLC customers.

If you havent been planning your upgrade already then you might want to review the list of improvements and additional features included in the new release, these include DPM's ability to back up data de-dupe volumes from Windows 2012, support for Windows 8 / 2012 in SCCM and Azure support in DPM/SCOM.

Kevin Greene (SCOM MVP) has a good article on the upgrade process for SCOM 2012 -
Part 1 : http://kevingreeneitblog.blogspot.ie/2012/12/scom-2012-installing-service-pack-1-rtm.html
Part 2 : http://kevingreeneitblog.blogspot.ie/2013/01/scom-2012-installing-service-pack-1-rtm.html
Part 3 : http://kevingreeneitblog.blogspot.ie/2013/01/scom-2012-installing-service-pack-1-rtm_2.html

I will be running through the SCCM and DPM upgrades on a later post.

Monday, 26 November 2012

Reset Microsoft Surface tablet to factory settings

My manager recently purchased two Microsoft surface tablets in the states and of course deployed one of these units to the MD, no big deal I thought (for testing purposes). However connecting it to our exchange server required a password change and this is where the fun began.

Following a successful password change, the password was subsequently forgotten (it happens to us all) and access to the Surface unit was locked. After a quick search in Google I found a link to a TechNet article (http://technet.microsoft.com/en-us/library/ee692045(v=surface.10).aspx) that provides step by step instructions to reset a Surface unit back to Windows Vista factory settings - oh dear god no.

Now for the correct way to reset the tablet in this event:


  1. Boot the Surface tablet to the Windows 8 logon screen
  2. With the keyboard left shift button held down tap the power icon and choose the restart option
  3. A menu will appear with several options, pick the Troubleshoot option
  4. Now you will be presented with options to wipe the device back to factory settings


Wednesday, 3 October 2012

SCOM Dashboard / Windows Auto Logon

I was recently requested to setup a SCOM dashboard which needed to be displayed in a public area of my office so employees and management could see live states of applications and our WAN infrastructure. 

Setting up the Visio web drawings was the easy part, linking them back to SCOM and setting various shades of green, amber and red for alerts etc. One thing that struck me though was the absence of TweakUI for the Windows 7 PC that would drive the dashboard screens, remember with the Microsoft TweakUI PowerToy you could very easily setup an auto logon account (obviously you need to ensure that the account is very restricted).

SysInternals offer their autologin utility (http://technet.microsoft.com/en-us/sysinternals/bb963905.aspx) but I wanted to have control over a number of machines across our network and the user / password combination for them.

Having prepared a new GPO which effectively turned the user accounts setup for the dashboard PC's into kiosks I stripped the additional registry keys that the autologin utility creates and added them into the group policy preferences/registry:



Keys required:

SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoAdminLogon
SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultDomainName
SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultPassword
SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName

With the new GPO supplied registry entries I can now specify targets for the DefaultPassword and DefaultUserName registry entries allowing me to control which user logs into which dashboard machine.

Another minor task made easier..

Tuesday, 11 September 2012

Software VSS Provider - DPM 2010/2012 Brick Level Backup

Even entry level SAN's today from vendors such as HP, Dell etc are offering hardware VSS software as standard, which is great for brick level backups of your Hyper-V virtual environment. 

But... What happens if you find yourself using a SAN without H/W snapshots or your financial director has locked away the key to the stationary room. The dilemma is then whether or not to go ahead and submit the proposal for the H/W snapshot licenses or use the build in software VSS provider in Windows.

It is at this stage you need to undertake a comprehensive review of the perils of using software VSS, these being the increased demands on your Hyper-V hosts, long backup times and the dreaded redirected I/O in a clustered environment.

Redirected I/O


When backing up CSV's you will need to rethink your VM placement, this is due to the fact that low level operations on CSV's in Windows 2008 R2 Hyper-V result in redirected I/O. This process locks the CSV for exclusive access by the CSV owner in order to take a consistent backup, the bad news is every other host in the cluster will need to read and write data over cluster communications network rather than the storage network.

When using H/W VSS providers the amount of time for redirected I/O to occur during a backup is limited to the time required to create the hardware snapshot (typically a couple of seconds), but when using a S/W VSS provider redirection will occur for the entire length of the backup. Obviously backing up large numbers of virtual machines during business hours becomes a non runner, however S/W VSS can be used to backup VM's as long as you plan your environment to suit the solution.

VM Placement

When planning to use the S/W VSS provider you need to consider a couple of key area's. As mentioned earlier you want to limit the amount of time you incur redirected I/O so you should setup protection groups by CSV rather than by logical groupings such as SQL servers for instance. VM's with VHD's on multiple CSV's are also going to be an issue as when a backup is called, every CSV which is associated with the VM will also go into redirected I/O mode.

Using manual migration or Systems Center Virtual Machine Manager you want to get to a point where by manageable quantities of virtual machines are located for your soon to be built brick level protection groups.

Serialisation - Backup Jobs

Once you have sorted out your CSV / VM placement design the next stage is to serialise backups by using registry entries and the DSConfig powershell script. This process ensures that DPM is made aware of virtual machine placement at a storage level and limits DPM as to how many VM's it can backup at a particular time.

Conclusion...

Once you plan your environment and follow the guidelines outlined (http://technet.microsoft.com/en-us/library/hh757922.aspx), using DPM for brick level backups with the software VSS provider can help you get to a good place with your entire virtual environment ready to restore in a click of a button.

Monday, 10 September 2012

Microsoft PKI Update - October Patch Tuesday

Patch Tuesday in October will present a new challenge to IT admins across the globe as Microsoft increase the minimum RSA key length supported by all operating systems going back as far as Windows XP SP3.

The new 1024 bit requirement has the potential to cause large scale issues if certs are not updated to reflect the new security requirements of the O/S. Be warned and read the below advisory in order to keep systems compliant.

Microsoft Customer Advisory : http://support.microsoft.com/kb/2661254
CAPI2 Logging Utility : http://support.microsoft.com/kb/2661254

Wednesday, 5 September 2012

The User Profile Service failed the logon. User profile cannot be loaded

During a recent deployment of Windows 7 Enterprise with SCCM I ran into a strange issue after adding the install updates into the task sequence. When the O/S loaded only users with administrative rights who had logged on to the machine previously (i.e. local admin in this case) could log on.

For all other users they received the following message:

 
"The User Profile Service service failed the logon"


Microsoft do have a KB on this issue (http://support.microsoft.com/kb/947215), however in my scenario the user profile didn't exist so the fixes did not apply.

Having looked at the logs it became apparent that files within the C:\Users\Default directories had altered security permissions following the Windows updates.

As a work around I added the following command line task to reset permissions to default on the C:\Users\Default directory.

 
Command : icacls C:\Users\Default\* /reset

Tuesday, 4 September 2012

Installing Windows 8 Remote Server Administation Tools (RSAT) onWindows 8 RTM

Windows RSAT tools are obviously a must have set of tools for any systems administrator, allowing you to control all aspects of your core server environment from the comfort of your Windows client.

During the Beta process of Windows 8, Microsoft released a version for the O/S (http://www.microsoft.com/en-ie/download/details.aspx?id=28972). The new RSAT tool provided support for Server 2012 whilst sacrificing support for earlier Hyper-V servers and clusters, something I am sure will be corrected in the full release of the Win 8 RSAT expected later this month.

If you really feel the need to get the BETA RSAT tools installed on the RTM build of Windows 8, you will need to force the installation by running the MSU from the command line / explorer will generate an error.

To force the install of Windows 8 RSAT beta simply follow the below procedure.

  1. Download the Windows 8 RSAT MSU in either of its 32bit or 64bit flavours available on the Microsoft Download site (see link above).
  2. Expand the MSU using the following example:
    (64 bit)
    expand –f:* C:\RSAT\MSU\Windows6.2-KB2693643-x64.msu C:\RSAT\EXPANDED



    (32 bit)
    expand –f:* C:\RSAT\MSU\Windows6.2-KB2693643-x86.msu C:\RSAT\EXPANDED
  3. Once the files are expanded you can use the Windows package manager (PKGMGR.exe) to install the update silently.

    pkgmgr /ip /m:C:\RSAT\Expanded\Windows6.2-KB2693643-x64.cab

  4. The package will install silently and will take up to 10 minutes depending on your hardware, you can monitor the PKGMGR.exe process to determine when the update is installed.
  5. Once the update is installed go into Control Panel, Programs and Features and Turn Windows Features on or off. You should notice that the remote administration tool are installed:


UPDATE : RSAT RTM released : http://www.microsoft.com/en-us/download/details.aspx?id=28972




     

    Thursday, 30 August 2012

    Remove Missing VM's - SCVMM 2010 / 2012

    Should you find yourself in a situation whereby you have removed a VM without removing it from virtual machine manager, you will have a "missing" entry that you are unable to remove via the management console.

    To remove the VM simply undertake the following actions:

    1. Stop the virtual machine manager service on your SCVMM server
    2. Log onto the SQL instance that houses the SCVMM database
    3. Locate the following table : dbo.tbl_WLC_VObject then edit the top 200 rows
    4. Confirm that the VM's listed with an Object state "220" are the missing or retired VM's
    5. Now run the following SQL script:

      BEGIN TRANSACTION T1

      DECLARE custom_cursor CURSOR FOR
      SELECT ObjectId from
      dbo.tbl_WLC_VObject WHERE [ObjectState] = 220
      DECLARE @ObjectId uniqueidentifier
      OPEN custom_cursor
      FETCH NEXT FROM custom_cursor INTO @ObjectId
      WHILE(@@fetch_status = 0)
       BEGIN
       DECLARE vdrive_cursor CURSOR FOR
       SELECT VDriveId, VHDId, ISOId from
       dbo.tbl_WLC_VDrive WHERE ParentId = @ObjectId
       DECLARE @VDriveId uniqueidentifier
       DECLARE @VHDId uniqueidentifier
       DECLARE @ISOId uniqueidentifier

       OPEN vdrive_cursor
       FETCH NEXT FROM vdrive_cursor INTO @VDriveId, @VHDId, @ISOId
       WHILE(@@fetch_status = 0)
       BEGIN
        DELETE FROM dbo.tbl_WLC_VDrive
               WHERE VDriveId = @VDriveId
        if(@VHDId is NOT NULL)
        BEGIN
             
         DELETE FROM dbo.tbl_WLC_VHD
         WHERE VHDId = @VHDId
         DELETE FROM dbo.tbl_WLC_PhysicalObject
         WHERE PhysicalObjectId = @VHDId
        END
        if(@ISOId is NOT NULL)
        BEGIN

         DELETE FROM dbo.tbl_WLC_ISO
                WHERE ISOId = @ISOId
         DELETE FROM dbo.tbl_WLC_PhysicalObject
         WHERE PhysicalObjectId = @ISOId
        END

           FETCH NEXT FROM vdrive_cursor INTO @VDriveId, @VHDId, @ISOId
         END
       CLOSE vdrive_cursor
       DEALLOCATE vdrive_cursor
      -----------------
       DECLARE floppy_cursor CURSOR FOR
       SELECT VFDId, vFloppyId from
       dbo.tbl_WLC_VFloppy WHERE HWProfileId = @ObjectId
       DECLARE @vFloppyId uniqueidentifier
       DECLARE @vfdId uniqueidentifier
       OPEN floppy_cursor
       FETCH NEXT FROM floppy_cursor INTO @vfdId, @vFloppyId
       WHILE(@@fetch_status = 0)
       BEGIN
            DELETE FROM dbo.tbl_WLC_VFloppy
        WHERE VFloppyId = @vFloppyId

        if(@vfdid is NOT NULL)
        BEGIN
         DELETE FROM dbo.tbl_WLC_VFD
         WHERE VFDId = @vfdId
         DELETE FROM dbo.tbl_WLC_PhysicalObject
         WHERE PhysicalObjectId = @vfdId

        END

           FETCH NEXT FROM floppy_cursor INTO @vfdId, @vFloppyId
         END
       CLOSE floppy_cursor
       DEALLOCATE floppy_cursor
      ----------------
       DECLARE checkpoint_cursor CURSOR FOR
       SELECT VMCheckpointId from
       dbo.tbl_WLC_VMCheckpoint WHERE VMId = @ObjectId
       DECLARE @vmCheckpointId uniqueidentifier
       OPEN checkpoint_cursor
       FETCH NEXT FROM checkpoint_cursor INTO @vmCheckpointId
       WHILE(@@fetch_status = 0)
       BEGIN
            DELETE FROM dbo.tbl_WLC_VMCheckpointRelation
        WHERE VMCheckpointId = @vmCheckpointId


           FETCH NEXT FROM checkpoint_cursor INTO @vmCheckpointId
         END
       CLOSE checkpoint_cursor
       DEALLOCATE checkpoint_cursor
      -------------------------
      ---------Clean checkpoint
       DELETE FROM dbo.tbl_WLC_VMCheckpoint
       WHERE VMId = @ObjectID

              exec [dbo].[prc_VMMigration_Delete_VMInfoAndLUNMappings] @ObjectId
              DECLARE @RefreshId uniqueidentifier
              exec [dbo].[prc_RR_Refresher_Delete] @ObjectId, @RefreshId

              DELETE FROM dbo.tbl_WLC_VAdapter
       WHERE HWProfileId = @ObjectId

              DELETE FROM dbo.tbl_WLC_VNetworkAdapter
       WHERE HWProfileId = @ObjectId
                     
              DELETE FROM dbo.tbl_WLC_VCOMPort
       WHERE HWProfileId = @ObjectId
              DELETE FROM dbo.tbl_WLC_HWProfile
              WHERE HWProfileId = @ObjectId
              DELETE FROM dbo.tbl_WLC_VMInstance
              WHERE VMInstanceId = @ObjectId
       DELETE FROM dbo.tbl_WLC_VObject
       WHERE ObjectId = @ObjectId
          FETCH NEXT FROM custom_cursor INTO @ObjectId
        END
      CLOSE custom_cursor
      DEALLOCATE custom_cursor
      COMMIT TRANSACTION T1


      Original  - http://technet.microsoft.com/en-us/library/ff641854.aspx
    6. Once the script has run start up the SCVMM services and open the console.
    7. Your missing VM's will now be absent from the console
    Warning : Editing any SQL databases should be carried out with extreme caution and a valid backup should be present to roll back to in the event of accidental deletion of critical data or unexpected results.

    Monday, 27 August 2012

    Removing Failed Servers in DPM 2012

    If you find yourself in a position whereby you have a failed or deleted virtual/physical server, your DPM server will report the agent as being "Unavailable". Once in this state you will be unable to uninstall the agent as DPM will attempt to talk to the server in question to remove it gracefully from its database.

    In order to get around this open the DPM Management Shell and run the following command:

    Remove-ProductionServer.ps1

    Once prompted enter the name of your DPM sever, e.g. DPMServer.contoso.com
    On the next prompt enter the FQDN of the failed server, e.g. FileServer1.contoso.com

    You should now receive the following confirmation that your server has been removed from DPM database

    Removed ProductionServer successfully

    Open the management tab from within the DPM Administrator Console and you should see that the failed server has been removed from your agents list.

    Friday, 24 August 2012

    Windows 8 Enterprise

    It's hard to believe its been a full week since I rushed into the office early to download and rebuild my HP Elitebook with Windows 8 Enterprise.

    Now a week down and I find the transition to the new Metro modern UI to be a smooth one and I find myself adapting to the latest way of getting around Microsoft's latest OS. Yes, The UI is ultimately intended for touch devices however if you set aside any misconceptions and get past the first few hours you find things are just as accessible on your non touch enabled device.

    I like many other of my fellow IT colleagues find that a mixture of pinning apps to the task bar and relearning the often under used Windows hotkeys can provide a totally new way of doing things, in my opinion in many ways this if for the better. As an administrator I find myself missing the RSAT tools that I had in the beta, however I will make do with RDP connections until the updated release is released to the masses in September.

    The experience has not been without its faults however as vendor driver support is still thin on the ground, this also extends to a/v providers such as McAfee leaving you to rely on the inbuilt Defender and BitLocker tools. The one issue that has perplexed me is the built in Hyper-V network settings as to date my laptop does not want to play ball sharing the connections between the host and VM.