Browse by Tags

Tagged Content List
  • Blog Post: PowerShell Direct & Waiting for an IP Address

    Here is an interesting problem. With PowerShell Direct it is possible to get connected to a PowerShell session inside a virtual machine before the virtual machine has received an IP address. While this is cool - it can result in annoying script failures. To handle this - if I am using PowerShell Direct...
  • Blog Post: PowerShell Direct + Hot Add NIC == Give me an IP address

    Here is a fun script snippet that is possible with Windows 10: function addNicWithIP ( [ string ] $VMName , $cred , [ string ] $Switch , [ string ] $IPaddress , [ string ] $subnetPrefixLength ){ $newNetAdapter = Add-VMNetworkAdapter -VMName $VMName -SwitchName $Switch -Passthru Write-Output "[ $(...
  • Blog Post: Sending a script file into the VM using PowerShell Direct

    Okay, PowerShell Direct is cool - but sometimes you just want to copy a script (or set of scripts) into the virtual machine and run them there. How can you do that? Fortunately - PowerShell Direct comes to the rescue. Here is a simple snippet that will send any text file from the host to the virtual...
  • Blog Post: Using PowerShell Direct for Script Locking

    Here is one of the most helpful code snippets that I have come up with using PowerShell Direct: function waitForPSDirect([string]$VMName, $cred){ Write-Output "[$($VMName)]:: Waiting for PowerShell Direct (using $($cred.username))" while ((icm -VMName $VMName -Credential $cred {"Test"} -ea SilentlyContinue...
  • Blog Post: PowerShell Direct - handling authentication for better scripting

    In Windows 10 (and Windows Server 2016 TP2) we introduced a great new feature called PowerShell Direct. You can read about it all here: http://blogs.technet.com/b/virtualization/archive/2015/05/14/powershell-direct-running-powershell-inside-a-virtual-machine-from-the-hyper-v-host.aspx In essence it...
  • Blog Post: Virtual PC Guy on GitHub

    Over the years I have posted many scripts and code samples on this blog. Often, I get queries from people about whether it is okay to modify them / redistribute them / etc... Well - I have now started the process of moving all these scripts over to GitHub where they are being published under the MIT...
  • Blog Post: Script: Image Factory for Hyper-V

    Update 7/20/2015: This script is now available on GitHub. Please go to http://github.com/BenjaminArmstrong/Hyper-V-PowerShell/tree/master/Image-Factory to get the latest version, and to contribute any changes and bug fixes. Summer has come to Seattle - which means that it is time for me to get going...
  • Blog Post: Using PowerShell to Ping Test a VM

    I have been spending some time creating PowerShell snippets to help when you need to troubleshoot / debug a Hyper-V environment. Here is a handy one-liner that I recently created: Get-VM "File Server" | Select -ExpandProperty NetworkAdapters | Select -ExpandProperty IPAddresses | %{Ping $_} When...
  • Blog Post: The Most Popular Hyper-V PowerShell Cmdlets - by Bing

    Last week Jose Barreto made an excellent post about using PowerShell and Bing to check the popularity of various SMB PowerShell cmdlets. Well, I could not resist doing the same with Hyper-V! I made a slight tweak to Jose's code - by storing my data in a hashtable. This made it easier to sort and output...
  • Blog Post: Hyper-V PowerShell One-Line-Challenge - Part 3

    After posting my Hyper-V one-line PowerShell snippets last week - I had numerous people ask me: "Can you make this export to a CSV file?". How could I resist the ability to make this command even longer? So here you are: Get-Volume | ?{$_.DriveLetter -ne $null} | select @{N='Drive Letter';E={$_.DriveLetter...
  • Blog Post: Using PowerShell to Look at a VM Configuration

    I was recently asked to provide a PowerShell sample that would let you see everything inside a virtual machine configuration file - without having to import the virtual machine in question. Here is what I put together: Function Expand-VMConfig ($VMConfig) { $tempVM = (Compare-VM -Copy -Path $VMConfig...
  • Blog Post: Hyper-V PowerShell One-Line-Challenge - Part 2

    Building on the Hyper-V PowerShell One-Liner that I posted on Monday - comes this even more complicated one-liner: Get-Volume | ?{$_.DriveLetter -ne $null} | select @{N='Drive Letter';E={$_.DriveLetter}},@{N='Free Space (GB)';E={"{0:N2}" -f ($_.SizeRemaining / 1GB)}},@{N='Space Used By VHDs (GB)';E...
  • Blog Post: Hyper-V PowerShell One-Line-Challenge

    While digging through my notes I came across an exchange between a colleague and I - where we were challenging each other to come up with the most impressive (and functional) "Hyper-V PowerShell One Liner". Here is an example of a good one: Get-Volume | ?{$_.DriveLetter -ne $null} | select @{N='Drive...
  • Blog Post: Hyper-V Script to move everything off of a physical disk

    Hyper-V storage migration makes it very easy to move virtual machines wherever you need them, while they are running. And in the past I have showed you how easy it is to use PowerShell to storage migrate all the virtual machines on your computer to a new location. However, over the winter break I...
  • Blog Post: Importing a Virtual Machine with an Incompatible Saved State

    This afternoon – an email arrived with the following question for me: “I’m working with on a Hyper-V migration with an import-vm component. I saw what I believe is your post on importing incompatible VMs. We are experiencing an issue where the incompatibility has to do with a bad saved state after the...
  • Blog Post: Looking at Memory Usage on Hosts when Creating a New VM

    In my house I have two Hyper-V servers running multiple virtual machines with dynamic memory enabled. This can make it a bit tricky when I want to create a new virtual machine - and I need to figure out the best server to use. Thankfully - this little bit of PowerShell comes to the rescue: "Hyper...
  • Blog Post: Importing a VM with VHDs in Different Paths

    I was recently given an interesting challenge.  I was asked to show how you could use PowerShell to import a virtual machine; where the virtual hard disks were stored in multiple different locations.  Now, if the virtual hard disks were all in a single location, you could just use the “VHDSourcePath...
  • Blog Post: Using Compare-VM on Compare-VM

    I have been spending a lot of time this week looking at all the functionality that is available in the Compare-VM PowerShell cmdlet in Hyper-V.  The core concept of Compare-VM is that it returns a “virtual machine compatibility report” that lets you know about any problems that exist with the virtual...
  • Blog Post: Using PowerShell to Live Migrate to a Computer with a Different Virtual Switch

    So far this week I have shown you how to register and how to import virtual machines with configuration problems using PowerShell.  However, the question I most often hear is this one: how do I use PowerShell to live migrate a virtual machine to another computer – where the virtual switch names...
  • Blog Post: Importing an Incompatible VM with PowerShell

    Yesterday I stepped through the process of registering an incompatible virtual machine with PowerShell .  But what if you want to import the virtual machine instead of registering it?  Well, the process is pretty much identical.  Replace Import-VM with Compare-VM, fix the incompatibilities...
  • Blog Post: Registering an Incompatible VM with PowerShell

    If you have ever tried to register a virtual machine in Hyper-V Manager, and the virtual machine was not compatible with your current computer, you would have seen something like this: This is a GUI experience that allows you to make changes to the incoming virtual machine in order to make it work on...
  • Blog Post: Veeam RDP virtual appliance for remote management of Hyper-V

    Hyper-V has a number of options available for remote management.  System Center Virtual Machine Manager provides a great remote management experience.  The in-box Hyper-V manager works remotely, even in workgroup environments .  And if all else fails – you can always use Remote Desktop...
  • Blog Post: Hyper-V WMI v2 Porting Guide

    I have been getting more and more questions about how to use the Hyper-V v2 WMI namespace recently – so I have just created a TechNet Wiki article that links to a number of samples / documentation pages about how to do this.  You can get all the details here: http://social.technet.microsoft.com...
  • Blog Post: Creating a Virtual Machine with WMI v2

    Most people use the built in Hyper-V PowerShell cmdlets to control Hyper-V these days.  That said, there are people out there who program directly to our WMI APIs.  In Windows Server 2012 we introduced a new WMI namespace – and recently I have been getting a number of questions about how to...
  • Blog Post: Rename the guest OS to match the virtual machine name on Hyper-V

    When you are managing a large number of virtual machines, it can get tricky to keep track of everything. One thing that I see many people doing to help with this is to make sure that the guest operating system has the same network name as the virtual machine name. This makes life a lot easier when moving...
Page 1 of 7 (165 items) 12345»