Posts Tagged ‘ laurensdekoning

PowerCLI: Reset CD-drives using PowerShell

As most of you know and probably experienced from time to time: when a Virtual Machine’s CD-drive is connected to an ISO-file on one of your Datastores or even connected to the physical drive of your ESX-host the migration due VMotion of a Virtual Machine will not work.

Normally this isn’t really a problem except if you put a ESX-host in Maintenance mode and Virtual Center will simply not tell you why the Maintenance mode process is hanging or even giving a time-out after 15 minutes for no obvious reason. Most of the times it’s a Virtual Machine which has a CD-drive connected to an ISO file. A waste of time if you ask me.

So to prevent this from happening I’ve written a simple PowerShell oneliner/script disconnect these CD-drives from the ISO-files or from the physical drives and set them to Client-drives which is ok for VMotion:

(Get-VM -Location :( Get-VMHost "your.esx.host")) | `
ForEach ( $_ ) { Get-CDDrive $_ | `
Where { $_.IsoPath.Length -gt 0 -OR $_.HostDevice.Length -gt 0 } | `
Set-CDDrive -NoMedia -Confirm:$False }

Instead of executing this just on one host you can also execute this for your entire cluster:

(Get-VM -Location :( Get-Cluster "Your Cluster Name")) | `
ForEach ( $_ ) { Get-CDDrive $_ | `
Where { $_.IsoPath.Length -gt 0 -OR $_.HostDevice.Length -gt 0 } | `
Set-CDDrive -NoMedia -Confirm:$False }

Or ofcourse, by Datacenter:

(Get-VM -Location :( Get-Datacenter "Your Datacenter Name")) | `
ForEach ( $_ ) { Get-CDDrive $_ | `
Where { $_.IsoPath.Length -gt 0 -OR $_.HostDevice.Length -gt 0 } | `
Set-CDDrive -NoMedia -Confirm:$False }

It’s as easy as that, now there will be no Virtual Machine interrupting your VMotions anymore and you can put your ESX hosts in maintenance mode without any problems ;)

Cheers!

Visual Studio 2010 Beta 1

Hi Everyone!

Welcome to my first blog post on my own blog page. This finally gives me the opportunity to write a bit more and add a bit more imagery than I can do on just Twitter. Now that being said, let’s get to where this post is about :)

Microsoft finally release the first Beta of Visual Studio 2010. Now I’m not a fulltime developer, but I enjoy to develop a thing or two every now and then. Besides that I really love to see what’s new in new versions.
So I downloaded the ISO-image from Microsoft’s MSDN and I started instaling it on my Windows 7 RC installation. The installation is no other than 2008 except the only difference is that it starts installing the Beta version of the .NET 4.0 Framework which I suppose should offer a bit more features than 3.5 did.

After the installation -and the inevitable reboot- I ran Visual Studio 2010 and configured the environment for Visual C# usage, simply because that’s the language I’ll be developing in ;)

visual-studio-splash

Read more