Archive

Archive for the ‘Powershell’ Category

PowerShell v5 September preview available

September 4th, 2014 No comments

Today I was just checking my tweets and saw that the PowerShell team had released a new build of the Windows Management Framework v5, this time its the September build and it works only on Windows Server 2012 R2 or Windows 8.1 and if you have a previous version that was released in july of the v5 you have to uninstall that first and then you can install this version

here is a quote from the PowerShell team at http://blogs.msdn.com/b/powershell/archive/2014/09/04/windows-management-framework-5-0-preview-september-2014-is-now-available.aspx

The following is a list of all the new scenarios enabled since May 2014:

  • Generate Windows PowerShell cmdlets based on an OData endpoint
  • Manage .ZIP files with new cmdlets
  • DSC Authoring Improvements in Windows PowerShell ISE
  • New Attribute for defining DSC meta-configuration
  • Use partial configurations DSC
  • Cross-computer synchronization through DSC
  • Get the current DSC configuration status
  • Compare, Update, and Publish DSC configurations
  • Audit Windows PowerShell usage by transcription and logging
  • Extract and parse structured objects out of string content
  • Extend the item noun to enable Symbolic Links
  • Develop with classes in Windows PowerShell
  • Register a PSRepository with PowerShell Get
  • Network Switch management through Windows PowerShell (improvements)

I used a Azure VM to test and install this version

win framework5preview

install

restart

And once rebooted I can check via Get-Host what version I am actually running

ps5

Categories: Powershell Tags:

Adding more external IP´s to your WAP NVGRE VM´s

June 3rd, 2014 No comments

So I have been during these two last days been in deep waters to find out a customers demands and the possibility to add more than one external IP to the same NVGRE enabled VM network within WAP and VMM and the Hyper-V Network Virtualization Gateway this as the ports from the external application the customer has cannot be altered and they need to access several different VM´s simultaneously.

Described in this visio diagram the customer wish is:

Drawing1

 

As you maybe know, within the VMM when you have configured the HNV there is no possibility to add more external addresses in the GUI and configure port forwarding.

networknatvmm

So how to do this then, well there is a way and that is called PowerShell on the HNV Gateway and first you add the external address and then add the NAT rules

Here is a screendump of an addition of a port rule:

newnetnatbinding

To get the NatName I added the first external IP and Port rules through VMM and then I could use that information when creating the rest config from within the HNV gateway.

The following cmdlets are available on the HNV GW

Screen Shot 2014-06-03 at 19.01.09

Observe though that when adding these things directly in the HNV GW you cannot manage these rules and IP addresses in Windows Azure Pack portal or VMM!

 

Channel 9 videos available from TechEd US 2014

May 23rd, 2014 No comments

New version of the Microsoft Virtual Machine Converter 2.0 and MAT

April 8th, 2014 No comments

Today Microsoft released the long awaited new version of the Virtual Machine Converter (the 1.0 version could be integrated with MAT but had limits in both VMware and Hyper-V latest releases). Microsoft has also released a new version of the MAT (migration automation toolkit) that supports the MVMC 2.0 to automate the migration!

Screen Shot 2014-04-08 at 19.20.57

New Features in MVMC 2.0

MVMC 2.0 release of MVMC includes the following new features:

    • Converts virtual disks that are attached to a VMware virtual machine to virtual hard disks (VHDs) that can be uploaded to Windows Azure.
    • Provides native Windows PowerShell capability that enables scripting and integration into IT automation workflows.
      Note The command-line interface (CLI) in MVMC 1.0 has been replaced by Windows PowerShell in MVMC 2.0.
    • Supports conversion and provisioning of Linux-based guest operating systems from VMware hosts to Hyper-V hosts.
    • Supports conversion of offline virtual machines.
    • Supports the new virtual hard disk format (VHDX) when converting and provisioning in Hyper-V in Windows Server® 2012 R2 and Windows Server 2012.
    • Supports conversion of virtual machines from VMware vSphere 5.5, VMware vSphere 5.1, and VMware vSphere 4.1 hosts Hyper-V virtual machines.
    • Supports Windows Server® 2012 R2, Windows Server® 2012, and Windows® 8 as guest operating systems that you can select for conversion

in the link you can read more about the MVMC functionality

As you can see in the wizard the option to upload the converted VM to Azure directly has been added

Screen Shot 2014-04-08 at 19.21.50

And now in this version we have native PowerShell with the MVMC PS module as described above:

Screen Shot 2014-04-08 at 20.05.11

I will show more in a later post how it can be used and how it works with both migrations to Hyper-V and also directly to Azure :-)

both MVMC and MAT can be read about and downloaded here

Categories: Azure, Hyper-V, Powershell, Virtualization, VMware Tags:

Automated PowerShell to keep your template vhd(x) IC updated

March 31st, 2014 No comments

For the Veeam Seminar I did some digging in how to check and also apply updated integrational components on virtual disks in the System Center VMM library and found Ben´s script which I altered to fit my goal. This is quite convenient based on that you can schedule it and always have updated IC´s on those VHDX in the library.

I check and get the current IC´s from one Hyper-V host and thus based on that if it has been updated I also get that update instead of using a copied IC version locally in the VMM server. The script runs on the VMM server and that is why I use the Mount-DiskImage cmdlet instead of the Mount-VHD as that does not work on a non-hyper-V enabled windows server.

Screen Shot 2014-03-30 at 10.42.33

 

 

 

Recordings and code from SMA and Powershell webinar with Veeam

March 29th, 2014 No comments

Last week I had two webinars together with Veeam in the subject of “Automating daunting virtualization tasks”. Now these have been uploaded and shared on Veeams web. One is in swedish and one in english. during the webinar I show some different tasks that can be managed and handled with the Service Management Automation (SMA) and utilizing PowerShell.

51075482-98cb-11e3-82f1-12313b12ccaf-large

here is the english version: http://www.veeam.com/videos/webinar-replay-service-management-automation-akerlund-en-3932.html

and here is the swedish version: http://www.veeam.com/videos/webinar-replay-service-management-automation-akerlund-sw-3649.html

Here are some of the tasks and the PowerShell code,

First one of the tasks was adding VM´s to cluster where I utilize the function in this link

Next task that can be automated that you always will have a percentage free on the C drive for the VM´s (it both shrinks and expands), I am utilizing the generation 2 VM´s so for this to work your VM´s have to be configured with this latest virtual hardware version on Hyper-V 2012 R2

As you can see when I extend the size I make the VHDx about 230 MB larger to be able to set the partition to the size calculated regarding the overhead of the virtual disk, so if I would have tried to make both the VHDx and partition 15GB it would fail..

The rest of the scripts will be uploaded later in a follow up post. Of course there can be improvements in the ways to do things and if you have any comments or ideas please share :-)

 

Updated Raiders of the lost Cluster VM´s PowerShell function

March 17th, 2014 No comments

In 2012 I did a blogpost about a PowerShell function to find VM´s on Hyper-V Cluster nodes that was not configured as cluster resources and thus not being Highly Available in case of a hardware failure or maintenance work on the Hyper-V hosts…

687883034_1836208864001_raiders-of-the-lost-ark-imax-trailer-still

I have today made an update to the function so that it only gives the VM´s that have either SMB or CSV storage and not if you for some reason have VM´s residing on local storage within your clusternodes which can be the case for domain controllers or other appliances etc..

Good luck in your raid for the Lost Ark ;-)

Categories: Hyper-V, Powershell, Virtualization Tags:

Veeam webinar 19/3: Automate daunting virtualization tasks with SMA

March 5th, 2014 No comments

On wednesday the 19th of March I will together with Veeam have a web seminar with the topic:

Screen Shot 2014-03-05 at 21.54.12

Automate daunting virtualization tasks  with SMA

Now that you have set up your virtualization environment, you’ll want to automate it. In this webinar, you will learn how to do this with Service Management Automation(SMA) and how to integrate automated tasks into the Hyper-V virtualization environment. You will use different runbooks to automate some boring but necessary tasks that IT admins have to do.

This webinar will show you how to:

  • Automate patching of virtualization hosts
  • Expand virtual hard disks based on usage
  • Automatically update integrational components on VMs
  • Automatically update virtual hard disk templates
  • Clean old snapshots that have been forgotten
  • And more…

If you want to register and be part of this crazy one hour with the Swedish Chef you can do it on the following link

And guess what, It comes in a swedish version also! Check out in the following link and if you understand Swedish, register here!

Why are my Hyper-V hosts in VMM reporting “Needs Attention”?

February 27th, 2014 No comments

If you are kind of new to System Center VMM console and wondering why after a while your hosts responds “Needs Attention” and checking the host properties and seeing that everything looks green in the status, then continue and read this post!

Screen Shot 2014-02-27 at 10.18.10

Screen Shot 2014-02-27 at 12.31.28

You can just extend the console by right-click the hosts bar and add the column with “Agent Version Status” and then you can see the reason for host status,

Screen Shot 2014-02-27 at 10.23.49

The reason for this “Upgrade Avail” is that the VMM server has been updated with some new patches/updates that came with Windows Update and now you need to update your hosts to have the new agent to properly talk to the VMM Server.

That can of course be done with PowerShell if you have quite some hosts…  You can of course also get the list of which hosts that need an update,

Screen Shot 2014-02-27 at 10.41.28

And then with the following command also update the hosts that need to

Screen Shot 2014-02-27 at 10.53.23

If you are wondering why I am filtering on Agent-Version -ne “0.0” is because in this environment there are several VMware hosts and they do not have a VMM agent but is recognised as managed hosts and appear when getting the “managed computers”

Good luck :-)

Categories: Hyper-V, Powershell, SCVMM, SysCtr, Virtualization Tags:

SCVMM VM property dialog crash console with missing vhd(x)

January 14th, 2014 No comments

Today I was at a customer and they had an interesting error in their virtualization environment with Hyper-V 2012 and SC VMM 2012 Sp1 (yes I know, it is not R2 but we are working on it). One of their Hyper-V hosts had a hardware memory failure which lead to the host crashing and the VM´s restarting on other hosts..

during this the VM´s that was on that host got an error in the VMM db, looking and handling the VM´s from Hyper-V manager or failover cluster manager was no problem. Every time we tried to refresh the VM´s showed the following error and the job did not succeed.

Screen Shot 2014-01-14 at 14.36.51

And when we tried to look at the properties on the VM from VMM the console just died, and that happened every time..

Screen Shot 2014-01-14 at 14.28.50

So how could we find the VM´s that was suffering from this, well PowerShell could be used and with the following we could get the amount of VM´s and also easily get a list of the VM´s names.

Screen Shot 2014-01-14 at 13.26.15

So how could we fix this then,

There is a cmdlet in VMM with a parameter that can be used,  Remove-SCVirtualMachine -Force , this will remove the VM but not the virtual hard disk as it cannot find it..

Screen Shot 2014-01-14 at 16.20.21

But because we want to keep the VM we will do a bit of a workaround

  1. Stop the vm in VMM  by Stop-SCVirtualMachine own01  (even if the vhd(x) is not seen by VMM it will shut down the actual VM)
  2. Remove the VM from the cluster in Failover cluster manager or with powershell (this will only remove the cluster instance but not the actual VM)
  3. Start the VM in Hyper-V manager or with PowerShell  Get-VM own01 -ComputerName HV01 | Start-VM
  4. Remove the VM from the VMM with Powershell using the -force  Get-SCVirtualMachine own01 | Remove-SCVirtualMachine -Force (as I have removed the VM from the cluster VMM cannot find it and delete the vm´s xml file etc)
  5. Add the running VM to the cluster again with hyper-V PowerShell and failover cluster powershell using Get-VM own01 -ComputerName HV01 | Add-VMToCluster (Get-Cluster HVCL30)
  6. refresh VM´s in VMM and see that now the own01 vm can open properties

The reason I start the VM after removing it from the failover cluster is that VMM should think it is in stopped state, because that makes it easier to remove! And as in Hyper-V 2012 I can add a running VM to a cluster I do not have to keep the VM shut down during the whole process but just to get it into the right state in VMM :-)

Not the easiest way but hey who had said that VMM was self-healing :-P And yes we are in the process of upgrading to R2 and hopefully this error will not reemerge in that version….