Archive

Archive for the ‘Powershell’ Category

Using PowerShell to download Teched Europe 2014 content

October 30th, 2014 2 comments

I have spent the evening exploring how to create a script to download the content from Teched with powerpoints and videos,

As some of you that follow me on twitter and other social media knows, I will be going to MVP summit in Redmond and the flight leaves early saturday morning and I wanted to be able to get the most important content from Channel 9.

My former colleague Tim has made a GUI session downloader and that is nice, but I wanted one with PowerShell and of course where I could select a category and in my case the CDP is most interesting.

I have borrowed some code to make the folders from Peter Schmidt, but went for the Invoke-RestMethod and also using BITS as the transfer engine.

It is just a simple script but still powerful, I check if the folder is already created and also if the files have been downloaded which means that I do not download the files again when new content has been added :-)

As you can see on the screendump I use switches for the different choices, so to download two different  you can use -CDP -WIN,

Updated 10 Nov: I have got an tip from Irwin to add info in the BITS transfer so you can see which PPT or Video that is currently downloading and updated the script with that :-)

Screen Shot 2014-11-10 at 20.50.25

 

The script is also on the Script Gallery at this link and please go in and vote if you like it.

Please also comment if you have ideas of improvement,  I have downloaded only -CDP as that one was my primary object for filling my HDD for the 10 hour flight over the atlantic and as I am a Hyper-V MVP with cloud and datacenter as a main interest :-) but you can choose if you want -All or just a couple of the different categories!

Categories: Automation, Powershell Tags:

Using Azure Automation to check health of Minecraft server in Azure

October 24th, 2014 No comments

As every responsible dad out there I have set up an Minecraft server to my daughter so she can play with her friends!

Screen Shot 2014-10-23 at 16.16.59

I  have deployed a Windows Server on Azure in which I installed the Minecraft server with the right mods, apparently that is important ;-) I have not myself got lost in the Minecraft world, maybe because I grew up in the 80´s and had games that was mega-pixel and now I want that high definition graphics!

To see that it is working and alive I wanted some kind health check so here Azure Automation comes into play! Of course there would have been easier ways but I want try new stuff and also test and see how Azure Automation works and can be utilized.

So I created a runbook that checks the status and try to remediate the issue if it is not working:

I have utilised the YAMS so that the Minecraft Server is handled by a Windows Service. If there is some outage or maintenance on Azure the VM can be restarted and then it is good to know that the Minecraft Server will start even if no user is logged in. If for some reason the YAMS service is stopped or the Minecraft Server has stopped my runbook can remidiate that!

In Azure Automation I can schedule a check every 1 hour:

Screen Shot 2014-10-23 at 16.25.24

And as you can see when checking a job it reports that my Minecraft server is working!

Screen Shot 2014-10-23 at 16.45.23

To connect to the VM´s powershell endpoint I have added SessionOption -SkipCACheck thus letting me connect without getting a cert from a trusted certificate authority or importing the servers cert. Saw this option on Tim´s blog post and borrowed it:-)

In the deployed VM I have also done as explained in the PowerShell Tip from powershell.com to be able to connect to it as it is not part of a domain and when PowerShell remoting is enabled it uses Kerberos by default and the Minecraft server is standalone thus Kerberos not working!

Probably I will do some tweaking and update the script later but you can at least see the possibilities and power of using Azure automation!

Categories: Automation, Azure, Powershell, Virtualization Tags:

Live migrating VM´s between clusters in VMM 2012 R2

October 17th, 2014 No comments

Today I have been doing some work at a customer creating a Hyper-V 2012 R2 Cluster and starting to live migrate VM´s from their Hyper-V 2012 Cluster.

Doing that from VMM gave me some errors and here is the solution so that if you happens to get into the same problem :-)

First of all, when added the new cluster to VMM I tried to live migrate a VM but got this error (12700)

Screen Shot 2014-10-17 at 19.30.43After a quick search on the net I found this blog post explaining the need to configure kerberos live migration and delegation between the hosts and also that the hosts needs an “Host Management Credentials” account set up in the properties! I had already set up the hosts to use Kerberos and delegation between and still got the above error but when checking the Run As account it was empty:

Screen Shot 2014-10-17 at 15.53.45The problem as you can see though, it is greyed out and cannot be altered, I tried to do add an account through PowerShell and there I got an answer that it had to be set on the cluster,

Screen Shot 2014-10-17 at 21.37.08

checking on the cluster properties in the VMM console there is nowhere to add or see the management credential

Screen Shot 2014-10-17 at 21.32.37

So back to PowerShell again:

 

Screen Shot 2014-10-17 at 21.54.19

And when this is set all the cluster hosts have this credential set and then when doing a Live Migration it succeeded :-)

 

 

 

 

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

Download SysCtr Tech Preview VHD´s with PowerShell

October 12th, 2014 No comments

Now that the Windows Server Technical Preview and also the System Center Technical Preview have arrived everyone wants to start testing, I have in an earlier post done some initial testing of the new Hyper-V features.

If you want to quickly test the released System Center Tech Preview then use the preinstalled VHD´s that helps you get up and running much faster than installing on your own :-)

The released System Center Tech Preview roles are

  • System Center Virtual Machine Manager
  • System Center Orchestrator
  • System Center Operations Manager
  • System Center Data Protection Manager
  • System Center Service Manager

I have in earlier post showed how you can download all the VHD´s for System Center 2012 R2 and of course I could not use that script right of the shelf for downloading the tech preview as someone have done changes on the web page, but here is it! And I have also added some more functionality for you to choose which of the roles you want or all.

First of the changes gives for some reason duplicates of each file url from the web page I collect the download url´s I want to download and to get around that I use the superduper cmdlet and parameter Select-Object -Unique which gives me an array with all files just once ;-)

Screen Shot 2014-10-12 at 21.24.57

Secondly with Invoke-WebRequest PowerShell uses IE under the hood and I get this dialogue and to get rid of that i use -BasicParsing and that lets PowerShell use its own parser.

Screen Shot 2014-10-12 at 21.15.10

And as you saw in the above screendump I utilize Switch parameters so you can choose which of the roles you want and here you can see the script and copy to your own lab server and start downloading to test!

And by the way, make sure that you either have enough storage available on C: or what drive and folder you want to save it to with the -Dest parameter!!

Observe also that you probably will start the download and go for a walk or sleep as it is quite some data that will be downloaded!

Happy testing!

Hyper-V in new Windows Server technical Preview

October 1st, 2014 No comments

So today Microsoft released their technical previews of Windows 10 and also of Windows Server

As an Hyper-V interested guy I wanted to check out some things in this build, there have already been a blog post about cool features such as rolling cluster updates so that you can have different versions in the Hyper-V cluster and keep the VM´s up all time during an upgrade.

There are some more info on the technet site discussing the different new features:

http://technet.microsoft.com/en-us/library/dn765471.aspx

I downloaded the Windows Server technical preview from my MSDN and started the installation, it was really fast (and yes I have an SSD)

Screen Shot 2014-10-01 at 20.47.40

In this screendump you can see that 5.0.9841.0 version of the PowerShell is included in the server technical preview

Screen Shot 2014-10-01 at 20.16.03

And as you can see there is 182 cmdlets for the new Hyper-V PowerShell module

Screen Shot 2014-10-01 at 20.15.20

After you have moved your 2012 or 2012 R2 VM´s you can update the VM configuration to the latest version but beware that once done that you cannot move those VM´s back to the old Hyper-V host.

Screen Shot 2014-10-01 at 21.48.18

A new feature in this version is also that you can make snapshots (yea I still not like Checkpoint name) that uses VSS, and if that is not available it will fail-back to standard snapshots

Screen Shot 2014-10-01 at 21.44.49

And still in this version you can via PowerShell enable Processor compability for those Windows NT server ;-)

Screen Shot 2014-10-01 at 21.49.22

Screen Shot 2014-10-01 at 21.50.33

When I get some more time I will dig some more into it and do a follow up post

happy testing!

 

Categories: Hyper-V, Powershell, Virtualization Tags:

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