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”

PowerShell to Promote Domain Controller

Windows ServerWhen testing Microsoft Dynamics GP, I often need a domain controller within my set of virtual machines. I’ve been promoting a server to be a domain controller manually, but it recently occurred to me that I could probably do the same task using PowerShell.

After doing some research, I came up with four commands which will rename and restart the server, install the Active Directory feature and add a forest.

To rename a server, run the following command, replacing the highligted section with the new server name:

Rename-computer -newname {server name}

Continue reading “PowerShell to Promote Domain Controller”

MDGP 2015 R2 Feature of the Day: Scriptable Provisioning & Management

Microsoft Dynamics GPMicrosoft Dynamics GP 2015 R2 will soon be released (due late May/early June and, as with previous releases, Microsoft have started a Feature of the Day series on the Inside Microsoft Dynamics GP Team blog. As I have done with the last three series, I’ll be reposting these blog posts here with a little commentary.

The third Feature of the Day is Scriptable Provisioning & Management.

A critical element in successfully delivering Microsoft Dynamics GP as a cloud offering is the ability to centralize and automate the provisioning and management of the application.

Automation speeds up delivery, minimizes human involvement which reduces costs and the possibility of human errors, and can provide self-service functionality to the end user.

This feature addS APIs and PowerShell cmdlets that will enable automated/scriptable GP provisioning and management.

The screen shot shows a list of the PowerShell cmdlets available:


Microsoft Dynamics GP 2015 PowerShell

Microsoft Dynamics GP 2013 R2 saw the introduction of some PowerShell cmdlets, to which this new set adds. At Perfect Image we have been doing an increasing amount of work with the web client and have also had a number of projects recently whereby new companies are being created on existing systems.

The cmdlets have the potential to speed up both the deployment of the web client and new companies.

It has been on my To Do list for a while to learn PowerShell, but I think I may have to move it up the list fairly quickly.

Click to show/hide the MDGP 2015 R2 Feature of the Day Series Index