Giter Club home page Giter Club logo

hyper-v-powershell's Introduction

Hyper-V-PowerShell

Scripts that primarily use the Hyper-V PowerShell interfaces driving virtual machines

hyper-v-powershell's People

Contributors

benjaminarmstrong avatar flcdrg avatar grantemsley avatar jakeoshins avatar mike1237 avatar pbolduc avatar peterschen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hyper-v-powershell's Issues

Proposal: Enhancements to how FactoryVariables are loaded

Edit: Sept 4, 2016 - updated text in Enhancement 2.

Just found this project the other day and it is great work. I was running a few images from my MSDN subscription and found:

  1. I need different images for certain editions (ie Win 10 Enterprise vs Professional)
  2. I need different product keys for different editions

I am more than willing to submit pull requests with these enhancements if there is a chance they will be merged into the main repository. I am creating this issue to start the conversation and work out the details before starting on changes.

A simple solution is to have a copy of the Factory.ps1 and FactoryVariables.ps1, but that breaks down quickly.

Enhancement 1
Allow optional parameter to Factory.ps1 that allows specifying which file contains the variables. If not supplied, it would default to the current file name:

param([string]$variables="FactoryVariables.ps1")

Enhancement 2
This enhancement extends to the first one. I have worked on a prototype to store all the OS specific variables in a csv file so that the number of parameters to Start-ImageFactory could be reduced. I have an example that I am currently testing:

images.csv

Factory.ps1 changes

and then the main script iterate over each of the configurations. I have consolidated Core/GUI and Generation 1 and Generation 2 to a single record. You can set each column to true and it will generate 4 image files (Core Gen 1, Core Gen 2, GUI Gen 1, GUI Gen 2). I also will build up the friendly name using the same pattern the current script do.

I am going to be busy over the next couple of weeks. I hope to be able to get back and test my changes more thoroughly. My goal is to ensure these changes to no break anyone that is using the current version. Using external csv file should be optional. I will submit a pull request and I confident everything is solid.

Make network configuration of factory vm configurable

In some scenarios you might want to have the ability to configure the network configuration as internet egress is only available for certain networks. An option should be added which enables a static configuration of the deployed factory vm.

Run command not cleaned up

When having a generic sysprep run as proposed in #2 the post sysprep script won't be executed as all Run commands were already cleaned up.

$workingDir Issue

No matter what I put into the "DIR" variable, it wouldn't take the text. It may be because of a space in the folder name, I don't know. However, proposed fix:
$workingDir = (Get-Item -Path ".\").FullName
Setting it to that actually did it for me. While I know this will only work for those who make sure everything is grouped, most of us would know to do that anyway... I hope?

Factory.ps1: Logging for the Script

The Factory.ps1 does not write log files. Thus, errors in larger environments are difficult to understand. Can this be activated or installed?

Factory.ps1 Test Internet Connection line 513

Hi Ben,

Great scripts, I am not a coder, but please find my small contribution below.

Just found a problem in the Factory.ps1 at line 513.

www.microsoft.com is not allowing the test internet connection. Which caused a loop in my virtual machines powershell window.

I replaced it with google.ie who are responding to ping.

I was then able to finish creating a gold image of Win 10 Pro version 2004.

Which worked very well,

Thanks to you and your fellow coders hard work.

Slan go foill,
Paul Kelly

2016 defaults to secure boot, and vms fail boot

Just tried rebuilding my vms for the first time in a while (since moving to 2016) and noticed that none of the VMs boot. I am getting an error that, when digging, seems to be related to secure boot. Seems that Gen2 VMs default to secure boot enabled.

Post-sysprep call breaks .vhd usage for PDT

The hook which calls Logon.ps1 for the first boot after sysprep breaks the usage of the created VHD with PDT as PDT itself inserts a unattend.xml and a RunOnce command. Either there should be an option to make it configurable whether one wants to use the VHD to feed PDT or the created VHD needs to be created in a way which supports the use of PDT afterwards.

DriveLetter error when Windows 10 VHD is loaded

Getting this error

PS D:\ImageFactory> .\Factory.ps1
5:14 PM - [Windows 10 Enterprise - Gen 2]::Starting a new cycle!
5:14 PM - [Windows 10 Enterprise - Gen 2]::Checking for existing Factory VM
5:14 PM - [Windows 10 Enterprise - Gen 2]::Base VHD exists - need to check for updates
5:14 PM - [Windows 10 Enterprise - Gen 2]::Create new differencing disk to check for updates
5:14 PM - [Windows 10 Enterprise - Gen 2]::Copy login file for update check, also make sure flag file is cleared
Copy-Item : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Destination'.
Specified method is not supported.
At D:\ImageFactory\Factory.ps1:826 char:65
+ ... ($ResourceDirectory)\bits" -Destination ($driveLetter + ":\") -Recurs ...
+                                             ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Copy-Item], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.PowerShell.Commands.CopyItemCommand

Out-File : Cannot find drive. A drive with the name 'E ' does not exist.
At D:\ImageFactory\Factory.ps1:828 char:43
+ ... ceHolders | Out-File -FilePath "$($driveLetter):\Bits\Logon.ps1" -Wid ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (E :String) [Out-File], DriveNotFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.OutFileCommand

Stepping through the debugger, loading the .vhdx file returns two drives - the first is the system drive (with a blank drive letter) and the second is the E drive - presumably the one we want.

Convert-WindowsImage.ps1 broken on 1709

Hi Ben, I know you do not support Convert-WindowsImage.ps1 from the TechNet Gallery. However, I am trying find out what changed from 1703 to 1709 of Windows 10 that breaks the image converter. Something changed in the API WimApplyImage from Wimgapi.dll

Any assistance you can provide would be appreciated.

This change breaks the vhdx creation in Hyper-V-PowerShell scripts on Windows 10.

I could try to modify to use the Convert-WindowsImage.ps1 from the NanoServerImageGenerator on Windows Server 2016 disk, but I am unsure about the licensing of that script. It says:

Use of this sample source code is subject to the terms of the Microsoft
license agreement under which you licensed this sample source code.

I know there is someone at Microsoft knows what changed with this API in 1709.

Here is the error you get when running the image factory on Windows 10 Pro 1709.

Exception calling "Apply" with "1" argument(s): "The directory or file cannot be created"

full log:

Windows(R) Image to Virtual Hard Disk Converter for Windows(R) 10
Copyright (C) Microsoft Corporation.  All rights reserved.
Version 10.0.9000.0.amd64fre.fbl_core1_hyp_dev(mikekol).141224-3000 Beta

INFO   : Opening ISO en_windows_server_2016_x64_dvd_9327751.iso...
INFO   : Looking for E:\sources\install.wim...

INFO   : Image 4 selected (ServerDataCenter)...
INFO   : Creating sparse disk...
INFO   : Attaching VHDX...
INFO   : Disk initialized with GPT...
INFO   : Disk partitioned
INFO   : System Partition created
INFO   : Boot Partition created
INFO   : System Volume formatted (with DiskPart)...
INFO   : Boot Volume formatted (with Format-Volume)...
INFO   : Access path (F:\) has been assigned to the System Volume...
INFO   : Access path (\\?\Volume{4a8daf5b-08cc-499f-ba80-456d6f68cb38}\) has been assigned to the Boot Volume...
INFO   : Applying image to VHDX. This could take a while...
ERROR  : Exception calling "Apply" with "1" argument(s): "The directory or file cannot be created"
INFO   : Log folder is C:\Users\Phil\AppData\Local\Temp\Convert-WindowsImage\ce2f5e7c-e52a-4e13-b296-fff0fa6e64af

INFO   : Closing Windows image...
INFO   : Closing VHDX...
INFO   : Closing ISO...
INFO   : Done.

Factory.ps1: Copy-Item and Out-File path not supported

Error while running Factory.ps1 (latest version).


Copy-Item : The given path's format is not supported.
At D:\ImageFactory\Factory.ps1:840 char:13

  •         Copy-Item "$($ResourceDirectory)\bits" -Destination ($dri ...
    
  •         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Copy-Item], NotSupportedException
    • FullyQualifiedErrorId : System.NotSupportedException,Microsoft.PowerShell.Commands.CopyItemCommand

Out-File : The given path's format is not supported.
At D:\ImageFactory\Factory.ps1:842 char:43

  • ... ceHolders | Out-File -FilePath "$($driveLetter):\Bits\Logon.ps1" -Wid ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : OpenError: (:) [Out-File], NotSupportedException
    • FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand

Files are left in the VHD

The directory/files %systemdrive%\Bits\PSWindowsUpdate and Convert-WindowsImageInfo.txt are left on the VHD and should be removed.

Nano support

Not sure if this makes sense, but if it does then it would be great to handle Nano too

ISO Image to Wim Conversion

It appears that when starting with the Windows 2012r2 evaluation ISO image it can't convert this to a WIM ready for building.. Have I missed something here ? Or do I need to build a fix ?


PS C:\ImageFactory> .\Factory.ps1
09:02 - [Windows Server 2012 R2 DataCenter with GUI]::Starting a new cycle!
09:02 - [Windows Server 2012 R2 DataCenter with GUI]::Checking for existing Factory VM
09:02 - [Windows Server 2012 R2 DataCenter with GUI]::No base VHD!
09:02 - [Windows Server 2012 R2 DataCenter with GUI]::Creating unattend file for base VHD
09:02 - [Windows Server 2012 R2 DataCenter with GUI]::Create base VHD using Convert-
Windows(R) Image to Virtual Hard Disk Converter for Windows(R) 10
Copyright (C) Microsoft Corporation. All rights reserved.
Version 10.0.9000.0.amd64fre.fbl_core1_hyp_dev(mikekol).141224-3000 Beta

INFO : Opening ISO 9600.16384.WINBLUE_RTM.130821-1623_X64FRE_SERVER_EVAL_EN-US-IRM_SSS_X64FREE_EN-US_DV5.ISO...
INFO : Looking for D:\sources\install.wim...

INFO : Image selected ()...
ERROR : Convert-WindowsImage only supports Windows 7 and Windows 8 WIM files. The specified image does not appear to
ontain one of those operating systems.
INFO : Log folder is C:\Users\ESUTCL~1\AppData\Local\Temp\Convert-WindowsImage\6f2e1372-3f2c-4e6e-b50e-e9e5b289d10b

INFO : Closing Windows image...
INFO : Closing ISO...

INFO : Done.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.