PowerShell for Hyper-V: Save VM

Hyper-VThis post is part of the series on PowerShell for Hyper-V.

The following PowerShell command can be used to save a virtual machine (replace the highlighted section with the name of your virtual machine):

Save-VM -Name {VM name}

PowerShell for Hyper-V: Shut Down VM

Hyper-VThis post is part of the series on PowerShell for Hyper-V.

The following PowerShell command can be used to shut down a virtual machine (replace the highlighted section with the name of your virtual machine):

Stop-VM -Name {VM name}

PowerShell for Hyper-V: Start VM

Hyper-VThis post is part of the series on PowerShell for Hyper-V.

The following PowerShell command can be used to start a virtual machine (replace the highlighted section with the name of your virtual machine):

Start-VM -Name {VM name}

PowerShell for Hyper-V: Avoid Error Running PowerShell Scripts

Hyper-VThis post is part of the series on PowerShell for Hyper-V.

If you try to run a PowerShell script, you will receive an error:

PowerShell error trying to run script

File C:TempResume HVVMs.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at 
https:/go.microsoft.com/fwlink/?LinkID=135170.
    + CategoryInfo          : SecurityError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnauthorizedAccess

This is deliberate on Microsoft’s part to make sure a script is not inadvertently run. You can enable running of scripts, but this is very risky.

However, there is a command you can run which will, for only the script being run, allow the script to run (replace the highlighted section with your script file):

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File {your script}

The relevant section is

-ExecutionPolicy Bypass

which tells PowerShell that it may bypass the execution policy restriction.

PowerShell for Hyper-V: Series Index

Hyper-VWhen I joined ISC Software Solutions I received a new work laptop. This gave me both the need and, importantly, the time to get everything setup as I need it. This included creating new demo VMs to use.

In the past, I had one VM for each version with everything installed. This time round I have created two VMs, one hosting a Domain Controller and the other a SQL Server, which I will then use with a version based server.

To make things a little easier, I have created some PowerShell scripts to handle the VMs. This is a short series of posts for the scripts I have (none of them are complex, but I’m posting them here for easy access.

Continue reading “PowerShell for Hyper-V: Series Index”

Hyper-V: ‘The requested operation could not be completed due to a file system limitation’

Hyper-VWhen I joined ISC Software I received a new laptop which was pretty much a blank slate except for Windows itself. This meant that I had to install and configure everything I needed (I prefer this as it means I can configure everything exactly as I want it).

Due to having an SSD, instead of an HDD, in the laptop, I also got an external SSD which I am using for hosting my virtual machines using Hyper-V.

I thought nothing of this, but when I tried to start a VM from the external SSD, I received the following error:

Hyper-V Manager error

...Failed to power on with the Error 'The requested operation could not be completed due to a file system limitation'.

I double checked the external SSD and discovered it had a File System of exFAT; I reformatted the SSD into NTFS copied the virtual hard disks back onto it and was able to successfully start the virtual machine.

Errors Starting Local by Flywheel

Local By FlywheelI fired up Local by Flywheel again recently to test some changes to a plugin; as it started I received a series of errors:

Error message

Error
Uh-oh! We ran into a hiccup when trying to start the Local Machine.
Unable to start the VM: C:Program FilesOracleVirtualBoxVBoxManage.exe startvm local-by-flywheel --type headless failed:

Continue reading “Errors Starting Local by Flywheel”

Local by Flywheel: Disable Other Hypervisors Before Installing Local by Flywheel

Local By FlywheelThis post is part of the series on Local by Flywheel.

Local by Flywheel works by installing VirtualBox; if you are running any other visrtualsiation software, you need to make sure that it, and the related hypervisor, is disabled.

In my case, I am using Hyper-V so will need to use bcdedit to stop the hypervisor via an elevated command prompt.

The command to use is:

Adminstrator: Command Prompt showing hypervisor successful disabled

bcdedit /set hypervisorlaunchtype off

Once the command has successfully completed, the machine will need to be rebooted; if a reboot is done performed, then the hypervisor will not be fully disabled and will cause problems.

Once you’ve finished installing and shutdown Local by Flywheel, you can restart the Hyper-V hypervisor using the following command (again a reboot will be required):

bcdedit /set hypervisorlaunchtype auto

Hyper-V Error Creating Virtual Machines

Hyper-VA while ago I was having problems with Hyper-V whenever I tried to start a VM after my laptop had been to sleep or after it was first started up.

That problem went away recently after I upgraded to Windows 10 by rebuilding the laptop. However, it seems the problem has migrated to whenever I try to create a new virtual machine:

The server encountered an error while creatng

New Virtual Machine Wizard

The server encountered an error while creating {server name}.

The operation failed.

An unexpected error occurred: Logon failure: the user has not been granted the requested logon type at this computer. (0x80070569).

The operation failed.

The Hyper-V Virtual Machine Management server encountered an under unexpected error: Logon failure: the user has not been granted the requested logon type at this computer. (0x80070569).

This is a lot less disruptive than the originally problem as I started VMs a lot more often than I create them. And fortunately, the fix is the same as last time, so the batch file I created can still be used.

Run the batch file and the VM can be created; and even better is that I can keep the New Virtual Machine Wizard open with all of the settings configured when I run the batch file. So if I forget to run the batch file before starting to create the VM, I don’t lose any work.

Batch Command To Restart Hyper-V

Hyper-VI got a new laptop at work recently (i7 16GB RAM 1080P) and have finally been able to pretty much transition away from VMWare to Hyper-V (which I use at home for my test system); I only have a final couple of VMs to recreate or migrate. It has not all been smooth sailing however, as I have found that if the laptop goes to sleep or is switched off the VMs cannot be started again.

I think this is something to do the AD group policy rather than an inherent problem as my Surface Pro 3 works fine.

The solution is to restart the Hyper-V Virtual Machine Management service, but going into Services every time for this was soon going to get annoying, so instead I created a batch file I can run from a keyboard shortcut containing the following two lines:

net stop vmms
net start vmms

These commands stop and then start the service allowing me to use the VMs.