Unpacking Software Livestream

Join our monthly Unpacking Software livestream to hear about the latest news, chat and opinion on packaging, software deployment and lifecycle management!

Learn More

Chocolatey Product Spotlight

Join the Chocolatey Team on our regular monthly stream where we put a spotlight on the most recent Chocolatey product releases. You'll have a chance to have your questions answered in a live Ask Me Anything format.

Learn More

Chocolatey Coding Livestream

Join us for the Chocolatey Coding Livestream, where members of our team dive into the heart of open source development by coding live on various Chocolatey projects. Tune in to witness real-time coding, ask questions, and gain insights into the world of package management. Don't miss this opportunity to engage with our team and contribute to the future of Chocolatey!

Learn More

Calling All Chocolatiers! Whipping Up Windows Automation with Chocolatey Central Management

Webinar from
Wednesday, 17 January 2024

We are delighted to announce the release of Chocolatey Central Management v0.12.0, featuring seamless Deployment Plan creation, time-saving duplications, insightful Group Details, an upgraded Dashboard, bug fixes, user interface polishing, and refined documentation. As an added bonus we'll have members of our Solutions Engineering team on-hand to dive into some interesting ways you can leverage the new features available!

Watch On-Demand
Chocolatey Community Coffee Break

Join the Chocolatey Team as we discuss all things Community, what we do, how you can get involved and answer your Chocolatey questions.

Watch The Replays
Chocolatey and Intune Overview

Webinar Replay from
Wednesday, 30 March 2022

At Chocolatey Software we strive for simple, and teaching others. Let us teach you just how simple it could be to keep your 3rd party applications updated across your devices, all with Intune!

Watch On-Demand
Chocolatey For Business. In Azure. In One Click.

Livestream from
Thursday, 9 June 2022

Join James and Josh to show you how you can get the Chocolatey For Business recommended infrastructure and workflow, created, in Azure, in around 20 minutes.

Watch On-Demand
The Future of Chocolatey CLI

Livestream from
Thursday, 04 August 2022

Join Paul and Gary to hear more about the plans for the Chocolatey CLI in the not so distant future. We'll talk about some cool new features, long term asks from Customers and Community and how you can get involved!

Watch On-Demand
Hacktoberfest Tuesdays 2022

Livestreams from
October 2022

For Hacktoberfest, Chocolatey ran a livestream every Tuesday! Re-watch Cory, James, Gary, and Rain as they share knowledge on how to contribute to open-source projects such as Chocolatey CLI.

Watch On-Demand

Boxstarter HyperV Module

This is not the latest version of Boxstarter HyperV Module available.

  • 1
  • 2
  • 3

2.9.14 | Updated: 05 May 2017

Downloads:

961,367

Downloads of v 2.9.14:

6,727

Software Author(s):

  • Matt Wrock

Boxstarter HyperV Module 2.9.14

This is not the latest version of Boxstarter HyperV Module available.

  • 1
  • 2
  • 3

All Checks are Passing

3 Passing Tests


Validation Testing Passed


Verification Testing Passed

Details

Scan Testing Successful:

No detections found in any package files

Details
Learn More

Deployment Method: Individual Install, Upgrade, & Uninstall

To install Boxstarter HyperV Module, run the following command from the command line or from PowerShell:

>

To upgrade Boxstarter HyperV Module, run the following command from the command line or from PowerShell:

>

To uninstall Boxstarter HyperV Module, run the following command from the command line or from PowerShell:

>

Deployment Method:

NOTE

This applies to both open source and commercial editions of Chocolatey.

1. Enter Your Internal Repository Url

(this should look similar to https://community.chocolatey.org/api/v2/)


2. Setup Your Environment

1. Ensure you are set for organizational deployment

Please see the organizational deployment guide

2. Get the package into your environment

  • Open Source or Commercial:
    • Proxy Repository - Create a proxy nuget repository on Nexus, Artifactory Pro, or a proxy Chocolatey repository on ProGet. Point your upstream to https://community.chocolatey.org/api/v2/. Packages cache on first access automatically. Make sure your choco clients are using your proxy repository as a source and NOT the default community repository. See source command for more information.
    • You can also just download the package and push it to a repository Download

3. Copy Your Script

choco upgrade boxstarter.hyperv -y --source="'INTERNAL REPO URL'" --version="'2.9.14'" [other options]

See options you can pass to upgrade.

See best practices for scripting.

Add this to a PowerShell script or use a Batch script with tools and in places where you are calling directly to Chocolatey. If you are integrating, keep in mind enhanced exit codes.

If you do use a PowerShell script, use the following to ensure bad exit codes are shown as failures:


choco upgrade boxstarter.hyperv -y --source="'INTERNAL REPO URL'" --version="'2.9.14'" 
$exitCode = $LASTEXITCODE

Write-Verbose "Exit code was $exitCode"
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
if ($validExitCodes -contains $exitCode) {
  Exit 0
}

Exit $exitCode

- name: Install boxstarter.hyperv
  win_chocolatey:
    name: boxstarter.hyperv
    version: '2.9.14'
    source: INTERNAL REPO URL
    state: present

See docs at https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html.


chocolatey_package 'boxstarter.hyperv' do
  action    :install
  source   'INTERNAL REPO URL'
  version  '2.9.14'
end

See docs at https://docs.chef.io/resource_chocolatey_package.html.


cChocoPackageInstaller boxstarter.hyperv
{
    Name     = "boxstarter.hyperv"
    Version  = "2.9.14"
    Source   = "INTERNAL REPO URL"
}

Requires cChoco DSC Resource. See docs at https://github.com/chocolatey/cChoco.


package { 'boxstarter.hyperv':
  ensure   => '2.9.14',
  provider => 'chocolatey',
  source   => 'INTERNAL REPO URL',
}

Requires Puppet Chocolatey Provider module. See docs at https://forge.puppet.com/puppetlabs/chocolatey.


4. If applicable - Chocolatey configuration/installation

See infrastructure management matrix for Chocolatey configuration elements and examples.

Package Approved

This package was approved as a trusted package on 07 Jun 2017.

Description

Boxstarter's HyperV module includes functionality for targeting Hyper-V guest VMs with the ability to automatically configure them for remote installation and to create or restore snapshots at installation time.


tools\setup.ps1
function Install-Boxstarter($here, $ModuleName, $installArgs = "") {
    $boxstarterPath=Join-Path $env:AppData Boxstarter
    if(!(test-Path $boxstarterPath)){
        mkdir $boxstarterPath
    }
    $packagePath=Join-Path $boxstarterPath BuildPackages
    if(!(test-Path $packagePath)){
        mkdir $packagePath
    }    
    foreach($ModulePath in (Get-ChildItem $here | ?{ $_.PSIsContainer })){
        $target=Join-Path $boxstarterPath $modulePath.BaseName
        if(test-Path $target){
            Remove-Item $target -Recurse -Force
        }
    }
    Copy-Item "$here\*" $boxstarterPath -Recurse -Force -Exclude ChocolateyInstall.ps1, Setup.*

    PersistBoxStarterPathToEnvironmentVariable "PSModulePath"
    PersistBoxStarterPathToEnvironmentVariable "Path"
    $binPath =  "$here\..\..\..\bin"
    $boxModule=Get-Module Boxstarter.Chocolatey
    if($boxModule) {
        if($boxModule.Path -like "$env:LOCALAPPDATA\Apps\*") {
            $clickonce=$true
        }
    }
    if(!$clickonce){
        Import-Module "$boxstarterPath\$ModuleName" -DisableNameChecking -Force -ErrorAction SilentlyContinue
    }
    $successMsg = @"
The $ModuleName Module has been copied to $boxstarterPath and added to your Module path. 
You will need to open a new console for the path to be visible.
Use 'Get-Module Boxstarter.* -ListAvailable' to list all Boxstarter Modules.
To list all available Boxstarter Commands, use:
PS:>Import-Module $ModuleName
PS:>Get-Command -Module Boxstarter.*

To find more info visit http://Boxstarter.org or use:
PS:>Import-Module $ModuleName
PS:>Get-Help Boxstarter
"@
    Write-Host $successMsg

    if($ModuleName -eq "Boxstarter.Chocolatey" -and !$env:appdata.StartsWith($env:windir)) {
        $desktop = $([System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::DesktopDirectory))
        $startMenu=$("$env:appdata\Microsoft\Windows\Start Menu\Programs\Boxstarter")
        if(!(Test-Path $startMenu)){
            mkdir $startMenu
        }
        $target="powershell.exe"
        $targetArgs="-ExecutionPolicy bypass -NoExit -Command `"&'$boxstarterPath\BoxstarterShell.ps1'`""

		if($installArgs -inotcontains "nodesktopicon") {
			$link = Join-Path $desktop "Boxstarter Shell.lnk"
			Create-Shortcut $link $target $targetArgs $boxstarterPath
		}
        $link = Join-Path $startMenu "Boxstarter Shell.lnk"
        Create-Shortcut $link $target $targetArgs $boxstarterPath

        Set-Content -Path "$binPath\BoxstarterShell.bat" -Force -Value "$target $TargetArgs"
    }
}

function Create-Shortcut($location, $target, $targetArgs, $boxstarterPath) {
    $wshshell = New-Object -ComObject WScript.Shell
    $lnk = $wshshell.CreateShortcut($location)
    $lnk.TargetPath = $target
    $lnk.Arguments = "$targetArgs"
    $lnk.WorkingDirectory = $boxstarterPath
    $lnk.IconLocation="$boxstarterPath\BoxLogo.ico"
    $lnk.Save()

	$tempFile = "$env:temp\TempShortcut.lnk"
		
	$writer = new-object System.IO.FileStream $tempFile, ([System.IO.FileMode]::Create)
	$reader = new-object System.IO.FileStream $location, ([System.IO.FileMode]::Open)
		
	while ($reader.Position -lt $reader.Length)
	{		
		$byte = $reader.ReadByte()
		if ($reader.Position -eq 22) {
			$byte = 34
		}
		$writer.WriteByte($byte)
	}
		
	$reader.Close()
	$writer.Close()
				
	Move-Item -Path $tempFile $location -Force
}
function PersistBoxStarterPathToEnvironmentVariable($variableName){
    $value = [Environment]::GetEnvironmentVariable($variableName, 'User')
    if($value){
        $values=($value -split ';' | ?{ !($_.ToLower() -match "\\boxstarter$")}) -join ';'
        $values+=";$boxstarterPath"
    } 
    elseif($variableName -eq "PSModulePath") {
        $values=[environment]::getfolderpath("mydocuments")
        $values +="\WindowsPowerShell\Modules;$boxstarterPath"
    }
    else {
        $values ="$boxstarterPath"
    }
    if(!$value -or !($values -contains $boxstarterPath)){
        $values = $values.Replace(';;',';')
        [Environment]::SetEnvironmentVariable($variableName, $values, 'User')
        $varValue = Get-Content env:\$variableName
        $varValue += ";$boxstarterPath"
        $varValue = $varValue.Replace(';;',';')
        Set-Content env:\$variableName -value $varValue
    }
}
tools\LICENSE.txt
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.
tools\chocolateyinstall.ps1
$tools = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
. (Join-Path $tools Setup.ps1)
try { 
    $ModuleName = (Get-ChildItem $tools | ?{ $_.PSIsContainer }).BaseName
    $preInstall = Join-Path $tools "$modulename.preinstall.ps1"
    if(Test-Path $preInstall) { .$preInstall }
    Install-Boxstarter $tools $ModuleName $env:chocolateyPackageParameters
} catch {
    write-output $_ | fl * -force
    throw $_.Exception
}
tools\Boxstarter.HyperV\Enable-BoxstarterVM.ps1
function Enable-BoxstarterVM {
<#
.SYNOPSIS
Opens WMI ports and LocalAccountTokenFilterPolicy for Workgroup Hyper-V VMs

.DESCRIPTION
Prepares a Hyper-V VM for Boxstarter Installation. Opening WMI 
ports if remoting is not enabled and enabling 
LocalAccountTokenFilterPolicy if the VM is not in a domain so 
that Boxstarter can later enable PowerShell Remoting.

Enable-BoxstarterVM will also restore the VM to a specified 
checkpoint or create a new checkpoint if the given checkpoint 
does not exist.

.Parameter Provider
The VM Provider to use.

.PARAMETER VMName
The name of the VM to enable.

.PARAMETER Credential
The Credential to use to test PSRemoting.

.PARAMETER CheckpointName
If a Checkpoint exists by this name, it will be restored. Otherwise one will be created.

.NOTES
PSRemoting must be enabled in order for Boxstarter to install to a remote machine. Bare 
Metal machines require a manual step of enabling it before remote Boxstarter installs 
will work. However, on a Hyper-V VM, Boxstarter can manage this by mounting and 
manipulating the VM's VHD. Boxstarter can open the WMI ports which enable it to create a 
Scheduled Task that will enable PSRemoting. For VMs that are not domain joined, 
Boxstarter will also enable LocalAccountTokenFilterPolicy so that local accounts can 
authenticate remotely.

For Non-HyperV VMs, use Enable-BoxstarterVHD to perform these adjustments on the VHD of 
the VM. The VM must be powered off and accessible.

.OUTPUTS
A BoxstarterConnectionConfig that contains the ConnectionURI of the VM Computer and 
the PSCredential needed to authenticate.

.EXAMPLE
$cred=Get-Credential domain\username
Enable-BoxstarterVM -Provider HyperV -VMName MyVM $cred

Prepares MyVM for a Boxstarter Installation

.EXAMPLE
Enable-BoxstarterVM -Provider HyperV -VMName MyVM $cred | Install-BoxstarterPackage MyPackage

Prepares MyVM and then installs MyPackage

.EXAMPLE
Enable-BoxstarterVM -Provider HyperV -VMName MyVM $cred ExistingSnapshot | Install-BoxstarterPackage MyPackage

Prepares MyVM, Restores ExistingSnapshot and then installs MyPackage

.EXAMPLE
Enable-BoxstarterVM -Provider HyperV -VMName MyVM $cred NewSnapshot | Install-BoxstarterPackage MyPackage

Prepares MyVM, Creates a new snapshot named NewSnapshot and then installs MyPackage

.LINK
http://boxstarter.org
Enable-BoxstarterVHD
Install-BoxstarterPackage
#>
    [CmdletBinding()]
    [OutputType([BoxstarterConnectionConfig])]
    param(
        [parameter(Mandatory=$true, ValueFromPipeline=$True, Position=0)]
        [string[]]$VMName,
        [parameter(Mandatory=$true, Position=1)]
        [Management.Automation.PsCredential]$Credential,
        [parameter(Mandatory=$false, Position=2)]
        [string]$CheckpointName
    )
    Begin {
        ##Cannot run remotely unelevated. Look into self elevating
        if(!(Test-Admin)) {
            Write-Error "You must be running as an administrator. Please open a PowerShell console as Administrator and rerun Install-BoxstarperPackage."
            return
        }

        if(!(Get-Command -Name Get-VM -ErrorAction SilentlyContinue)){
            Write-Error "Boxstarter could not find the Hyper-V PowerShell Module installed. This is required for use with Boxstarter.HyperV. Run Install-windowsfeature -name hyper-v -IncludeManagementTools."
            return
        }

        $CurrentVerbosity=$global:VerbosePreference

        if($PSBoundParameters["Verbose"] -eq $true) {
            $global:VerbosePreference="Continue"
        }
    }

    Process {
        $VMName | % { 

            $vm=Get-VM $_ -ErrorAction SilentlyContinue
            if($vm -eq $null){
                throw New-Object -TypeName InvalidOperationException -ArgumentList "Could not find VM: $_"
            }

            if($CheckpointName -ne $null -and $CheckpointName.Length -gt 0){
                $point = Get-VMSnapshot -VMName $_ -Name $CheckpointName -ErrorAction SilentlyContinue
                $origState=$vm.State
                if($point -ne $null) {
                    Restore-VMSnapshot -VMName $_ -Name $CheckpointName -Confirm:$false
                    Write-BoxstarterMessage "$checkpointName restored on $_ waiting to complete..."
                    $restored=$true
                }
            }

            if($vm.State -eq "saved"){
                Remove-VMSavedState $_
            }

            if($vm.State -ne "running"){
                Start-VM $_ -ErrorAction SilentlyContinue
                Wait-HeartBeat $_
            }

            do {
                Start-Sleep -milliseconds 100
                $ComputerName=Get-VMGuestComputerName $_
            } 
            until ($ComputerName -ne $null)
            $clientRemoting = Enable-BoxstarterClientRemoting $ComputerName
            Write-BoxstarterMessage "Testing remoting access on $ComputerName..."
            $remotingTest = Invoke-Command $ComputerName { Get-WmiObject Win32_ComputerSystem } -Credential $Credential -ErrorAction SilentlyContinue
        
            $params=@{}
            if(!$remotingTest) {
                Log-BoxstarterMessage "PowerShell remoting connection failed:"
                if($global:Error.Count -gt 0) { Log-BoxstarterMessage $global:Error[0] }
                write-BoxstarterMessage "Testing WSMAN..."
                $WSManResponse = Test-WSMan $ComputerName -ErrorAction SilentlyContinue
                if($WSManResponse) { 
                    Write-BoxstarterMessage "WSMAN responded. Will not enable WMI." -verbose
                    $params["IgnoreWMI"]=$true
                }
                else {
                    Log-BoxstarterMessage "WSMan connection failed:"
                    if($global:Error.Count -gt 0) { Log-BoxstarterMessage $global:Error[0] }
                    write-BoxstarterMessage "Testing WMI..."
                    $wmiTest=try { Invoke-WmiMethod -ComputerName $ComputerName -Credential $Credential Win32_Process Create -Args "cmd.exe" -ErrorAction SilentlyContinue } catch {$ex=$_}
                    if($wmiTest -or ($ex -ne $null -and $ex.CategoryInfo.Reason -eq "UnauthorizedAccessException")) { 
                        Write-BoxstarterMessage "WMI responded. Will not enable WMI." -verbose
                        $params["IgnoreWMI"]=$true
                    }
                    else {
                        Log-BoxstarterMessage "WMI connection failed:"
                        if($global:Error.Count -gt 0) { Log-BoxstarterMessage $global:Error[0] }
                    }
                }
                $credParts = $Credential.UserName.Split("\\")
                if(($credParts.Count -eq 1 -and $credParts[0] -eq "administrator") -or `
                  ($credParts.Count -eq 2 -and $credParts[0] -eq $ComputerName -and $credParts[1] -eq "administrator") -or`
                  ($credParts.Count -eq 2 -and $credParts[0] -ne $ComputerName)){
                    $params["IgnoreLocalAccountTokenFilterPolicy"]=$true
                }
                if($credParts.Count -eq 2 -and $credParts[0] -eq $ComputerName -and $credParts[1] -eq "administrator"){
                    $params["IgnoreLocalAccountTokenFilterPolicy"]=$true
                }

            }

            if(!$remotingTest -and ($params.Count -lt 2)) { 
                Write-BoxstarterMessage "Stopping $_"
                Stop-VM $_ -WarningAction SilentlyContinue -ErrorAction SilentlyContinue
                $vhd=Get-VMHardDiskDrive -VMName $_
                Enable-BoxstarterVHD $vhd.Path @params | Out-Null
                Start-VM $_
                Write-BoxstarterMessage "Started $_. Waiting for Heartbeat..."
                Wait-HeartBeat $_
            }

            if(!$restored -and $CheckpointName -ne $null -and $CheckpointName.Length -gt 0) {
                Write-BoxstarterMessage "Creating Checkpoint $CheckpointName"
                Checkpoint-VM -Name $_ -SnapshotName $CheckpointName
            }

            $res=new-Object -TypeName BoxstarterConnectionConfig -ArgumentList "http://$($computerName):5985/wsman",$Credential,$null
            return $res
        }
    }

    End {
        $global:VerbosePreference=$CurrentVerbosity
    }
}

function Get-VMGuestComputerName($vmName) {
    $vm = Get-WmiObject -Namespace root\virtualization\v2 -Class Msvm_ComputerSystem -Filter "ElementName='$vmName'"
    $vm.GetRelated("Msvm_KvpExchangeComponent").GuestIntrinsicExchangeItems | % {
        if(([XML]$_) -ne $null){
            $GuestExchangeItemXml = ([XML]$_).SelectSingleNode("/INSTANCE/PROPERTY[@NAME='Name']/VALUE[child::text()='FullyQualifiedDomainName']") 
        
            if ($GuestExchangeItemXml -ne $null) { 
                $GuestExchangeItemXml.SelectSingleNode("/INSTANCE/PROPERTY[@NAME='Data']/VALUE/child::text()").Value 
            }
        }
    }    
}

function Wait-HeartBeat($vmName) {
    do {Start-Sleep -milliseconds 100} 
    until ((Get-VMIntegrationService -VMName $vmName | ?{$_.id.endswith("\\84EAAE65-2F2E-45F5-9BB5-0E857DC8EB47") -or ($_.name -eq "Heartbeat")}).PrimaryStatusDescription -eq "OK")
}
tools\Boxstarter.HyperV\Enable-BoxstarterVHD.ps1
function Enable-BoxstarterVHD {
<#
.SYNOPSIS
Enables WMI and LocalAccountTokenFilterPolicy in a VHD's Windows Registry

.DESCRIPTION
Prepares a VHD for Boxstarter Installation. Opening WMI ports and enabling 
LocalAccountTokenFilterPolicy so that Boxstarter can later enable 
PowerShell Remoting.

.PARAMETER VHDPath
The path to the VHD file

.PARAMETER IgnoreWMI
If specified, WMI ports will not be enabled

.PARAMETER IgnoreLocalAccountTokenFilterPolicy
If specified, IgnoreLocalAccountTokenFilterPolicy will not be enabled

.NOTES
The VHD must be accessible, writable and contain a system drive.

.OUTPUTS
The computer name stored in the VHD's Windows Registry

.EXAMPLE
$ComputerName = Enable-BoxstarterVHD $pathToVHD

Enables IgnoreLocalAccountTokenFilterPolicy and WMI ports in the Windows registry

.EXAMPLE
$ComputerName = Enable-BoxstarterVHD $pathToVHD -IgnoreWMI

Enables IgnoreLocalAccountTokenFilterPolicy in the Windows registry

.EXAMPLE
$ComputerName = Enable-BoxstarterVHD $pathToVHD -IgnoreLocalAccountTokenFilterPolicy

Enables WMI ports in the Windows registry

.LINK
http://boxstarter.org

#>
    [CmdletBinding()]
    param(
        [Parameter(Position=0,Mandatory=$true)]
        [ValidateScript({Test-Path $_})]
        [ValidatePattern("\.(a)?vhd(x)?$")]
        [string]$VHDPath,
        [switch]$IgnoreWMI,
        [switch]$IgnoreLocalAccountTokenFilterPolicy
    )
    $CurrentVerbosity=$global:VerbosePreference
    try {

        if($PSBoundParameters["Verbose"] -eq $true) {
            $global:VerbosePreference="Continue"
        }

        if(!(Get-Command -Name Get-VM -ErrorAction SilentlyContinue)){
            Write-Error "Boxstarter could not find the Hyper-V PowerShell Module installed. This is required for use with Boxstarter.HyperV. Run Install-windowsfeature -name hyper-v -IncludeManagementTools."
            return
        }

        if((Get-ItemProperty $VHDPath -Name IsReadOnly).IsReadOnly){
            throw New-Object -TypeName InvalidOperationException -ArgumentList "The VHD is Read-Only"
        }    
        $before = (Get-Volume).DriveLetter | ? { $_ -ne $null }
        mount-vhd $VHDPath
        $after = (Get-Volume).DriveLetter | ? { $_ -ne $null }
        $winVolume = compare $before $after -Passthru
        Write-BoxstarterMessage "Drives added after mount are $($winVolume)" -Verbose
        $winVolume | % { new-PSDrive -Name $_ -PSProvider FileSystem -Root "$($_):\" -ErrorAction SilentlyContinue | out-null}
        try{
            $sysVolume = $winVolume | ? {Test-Path "$($_):\windows\System32\config"}
            if($sysVolume -eq $null){
                throw New-Object -TypeName InvalidOperationException -ArgumentList "The VHD does not contain system volume"
            }    
            Write-BoxstarterMessage "Mounted $VHDPath with system volume to Drive $($sysVolume)"
            if(!$IgnoreLocalAccountTokenFilterPolicy) {
                reg load HKLM\VHDSOFTWARE "$($sysVolume):\windows\system32\config\software" | out-null
                $policyResult = reg add HKLM\VHDSOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f
                Write-BoxstarterMessage "Enabled LocalAccountTokenFilterPolicy with result: $policyResult"
            }

            reg load HKLM\VHDSYS "$($sysVolume):\windows\system32\config\system" | out-null
            $current=Get-CurrentControlSet
            $computerName = (Get-ItemProperty "HKLM:\VHDSYS\ControlSet00$current\Control\ComputerName\ComputerName" -Name ComputerName).ComputerName

            if(!$IgnoreWMI){
                (Get-Item (Get-FireWallKey)).Property | ? { $_-like 'wmi-*' } | % { Enable-FireWallRule $_}
                Write-BoxstarterMessage "Enabled WMI Firewall Rules."
            }

            return "$computerName"
        }
        finally{
            [GC]::Collect() # The next line will fail without this since handles to the loaded hive have not yet been collected
            reg unload HKLM\VHDSOFTWARE 2>&1 | out-null
            reg unload HKLM\VHDSYS 2>&1 | out-null
            Write-BoxstarterMessage "VHD Registry Unloaded" -Verbose
            Dismount-VHD $VHDPath
            Write-BoxstarterMessage "VHD Dismounted"
        }
    }
    finally{
        $global:VerbosePreference=$CurrentVerbosity
    }
}

function Enable-FireWallRule($ruleName){
    $key=Get-FirewallKey
    $rules = Get-ItemProperty $key
    $rule=$rules.$ruleName
    $newVal = $rule.Replace("|Active=FALSE|","|Active=TRUE|")
    Set-ItemProperty $key -Name $ruleName -Value $newVal
    Write-BoxstarterMessage "Changed $ruleName firewall rule to: $newVal" -Verbose
}

function Disable-FireWallRule($ruleName){
    $key=Get-FirewallKey
    $rules = Get-ItemProperty $key
    $rule=$rules.$ruleName
    $newVal = $rule.Replace("|Active=TRUE|","|Active=FALSE|")
    Set-ItemProperty $key -Name $ruleName -Value $newVal
    Write-BoxstarterMessage "Changed $ruleName firewall rule to: $newVal" -Verbose
}

function Get-FireWallKey{
    $current = Get-CurrentControlSet
    return "HKLM:\VHDSYS\ControlSet00$current\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules"
}

function Get-CurrentControlSet {
    return (Get-ItemProperty "HKLM:\VHDSYS\Select" -Name Current).Current

}
tools\Boxstarter.HyperV\Boxstarter.HyperV.pssproj
 
tools\Boxstarter.HyperV\BoxStarter.HyperV.psm1
$unNormalized=(Get-Item "$PSScriptRoot\..\Boxstarter.Chocolatey\Boxstarter.Chocolatey.psd1")
Import-Module $unNormalized.FullName -global -DisableNameChecking -Force
Resolve-Path $PSScriptRoot\*-*.ps1 | 
    % { . $_.ProviderPath }

Export-ModuleMember Enable-BoxstarterVM, Enable-BoxstarterVHD
tools\Boxstarter.HyperV\Boxstarter.HyperV.psd1
@{
Description = 'Provides Cmdlets that will install a Boxstarter package on a Hyper-V VM'
# Script module or binary module file associated with this manifest.
ModuleToProcess = './boxstarter.HyperV.psm1'

# Version number of this module.
ModuleVersion = '2.9.14'

# ID used to uniquely identify this module
GUID = 'bbdb3e8b-9daf-4c00-a553-4f3f88fb6e58'

# Author of this module
Author = 'Matt Wrock'

# Copyright statement for this module
Copyright = '(c) 2016 Matt Wrock'

# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '3.0'

# Minimum version of the .NET Framework required by this module
DotNetFrameworkVersion = '4.0'

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
NestedModules = @('..\Boxstarter.Common\Boxstarter.Common.psd1','..\Boxstarter.Chocolatey\Boxstarter.Chocolatey.psd1')

# Functions to export from this module
FunctionsToExport = '*'

# Cmdlets to export from this module
CmdletsToExport = '*'

# Variables to export from this module
VariablesToExport = '*'

# Aliases to export from this module
AliasesToExport = '*'

# List of all modules packaged with this module.
# ModuleList = @()

# List of all files packaged with this module
# FileList = @()

# Private data to pass to the module specified in RootModule/ModuleToProcess
PrivateData = '25c0f89d72142d602928b4bd51e2da38fddb5814'

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''

}


Log in or click on link to see number of positives.

In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).

Chocolatey Pro provides runtime protection from possible malware.

Add to Builder Version Downloads Last Updated Status
Boxstarter HyperV Module 3.0.2 34317 Monday, June 12, 2023 Approved
Boxstarter HyperV Module 3.0.1 3978 Tuesday, June 6, 2023 Approved
Boxstarter HyperV Module 3.0.0 90346 Thursday, July 14, 2022 Approved
Boxstarter HyperV Module 3.0.0-beta-20220427-21 118 Wednesday, April 27, 2022 Exempted
Boxstarter HyperV Module 2.13.0 150889 Thursday, October 15, 2020 Approved
Boxstarter HyperV Module 2.12.0 383615 Tuesday, October 30, 2018 Approved
Boxstarter HyperV Module 2.11.0 63657 Wednesday, May 16, 2018 Approved
Boxstarter HyperV Module 2.10.3 51184 Thursday, August 31, 2017 Approved
Boxstarter HyperV Module 2.9.26 5153 Monday, June 19, 2017 Approved
Boxstarter HyperV Module 2.9.24 775 Sunday, June 18, 2017 Approved
Boxstarter HyperV Module 2.9.14 6727 Friday, May 5, 2017 Approved
Boxstarter HyperV Module 2.9.5 4642 Thursday, March 30, 2017 Approved
Boxstarter HyperV Module 2.9.2 1132 Monday, March 27, 2017 Approved
Boxstarter HyperV Module 2.8.29 30192 Sunday, May 22, 2016 Approved
Boxstarter HyperV Module 2.8.27 410 Sunday, May 22, 2016 Approved
Boxstarter HyperV Module 2.8.21 1019 Thursday, April 28, 2016 Approved
Boxstarter HyperV Module 2.8.18 674 Tuesday, April 26, 2016 Approved
Boxstarter HyperV Module 2.8.12 1154 Thursday, April 21, 2016 Approved
Boxstarter HyperV Module 2.8.0 1130 Friday, April 15, 2016 Approved
Boxstarter HyperV Module 2.7.0 1977 Sunday, April 3, 2016 Approved
Boxstarter HyperV Module 2.6.41 3514 Sunday, February 28, 2016 Approved
Boxstarter HyperV Module 2.6.25 6342 Friday, December 18, 2015 Approved
Boxstarter HyperV Module 2.6.20 540 Thursday, December 17, 2015 Approved
Boxstarter HyperV Module 2.6.16 708 Tuesday, December 15, 2015 Approved
Boxstarter HyperV Module 2.6.2 688 Monday, December 14, 2015 Approved
Boxstarter HyperV Module 2.6.0 499 Sunday, December 13, 2015 Approved
Boxstarter HyperV Module 2.5.21 8572 Thursday, August 13, 2015 Approved
Boxstarter HyperV Module 2.5.19 1941 Sunday, July 26, 2015 Approved
Boxstarter HyperV Module 2.5.10 1751 Friday, July 10, 2015 Approved
Boxstarter HyperV Module 2.5.3 1311 Wednesday, July 1, 2015 Approved
Boxstarter HyperV Module 2.5.1 540 Wednesday, July 1, 2015 Approved
Boxstarter HyperV Module 2.4.209 4365 Sunday, April 26, 2015 Approved
Boxstarter HyperV Module 2.4.205 2041 Sunday, April 5, 2015 Approved
Boxstarter HyperV Module 2.4.196 1441 Friday, March 20, 2015 Approved
Boxstarter HyperV Module 2.4.188 1315 Monday, March 9, 2015 Approved
Boxstarter HyperV Module 2.4.183 837 Wednesday, March 4, 2015 Approved
Boxstarter HyperV Module 2.4.180 565 Tuesday, March 3, 2015 Approved
Boxstarter HyperV Module 2.4.179 506 Tuesday, March 3, 2015 Approved
Boxstarter HyperV Module 2.4.159 2762 Sunday, January 18, 2015 Approved
Boxstarter HyperV Module 2.4.157 681 Thursday, January 15, 2015 Approved
Boxstarter HyperV Module 2.4.152 824 Monday, January 12, 2015 Approved
Boxstarter HyperV Module 2.4.149 1390 Friday, December 26, 2014 Approved
Boxstarter HyperV Module 2.4.146 473 Friday, December 26, 2014 Approved
Boxstarter HyperV Module 2.4.128 1969 Thursday, November 27, 2014 Approved
Boxstarter HyperV Module 2.4.123 3847 Wednesday, September 24, 2014 Approved
Boxstarter HyperV Module 2.4.110 823 Wednesday, September 17, 2014 Approved
Boxstarter HyperV Module 2.4.93 768 Friday, September 12, 2014 Approved
Boxstarter HyperV Module 2.4.88 1039 Wednesday, September 3, 2014 Approved
Boxstarter HyperV Module 2.4.87 461 Wednesday, September 3, 2014 Approved
Boxstarter HyperV Module 2.4.80 2769 Monday, August 4, 2014 Approved
Boxstarter HyperV Module 2.4.76 544 Sunday, August 3, 2014 Approved
Boxstarter HyperV Module 2.4.70 700 Thursday, July 31, 2014 Approved
Boxstarter HyperV Module 2.4.67 732 Wednesday, July 30, 2014 Approved
Boxstarter HyperV Module 2.4.61 710 Monday, July 28, 2014 Approved
Boxstarter HyperV Module 2.4.57 494 Sunday, July 27, 2014 Approved
Boxstarter HyperV Module 2.4.54 747 Wednesday, July 23, 2014 Approved
Boxstarter HyperV Module 2.4.53 500 Wednesday, July 23, 2014 Approved
Boxstarter HyperV Module 2.4.51 488 Wednesday, July 23, 2014 Approved
Boxstarter HyperV Module 2.4.48 563 Tuesday, July 22, 2014 Approved
Boxstarter HyperV Module 2.4.46 607 Saturday, July 19, 2014 Approved
Boxstarter HyperV Module 2.4.41 699 Sunday, July 13, 2014 Approved
Boxstarter HyperV Module 2.4.39 521 Sunday, July 13, 2014 Approved
Boxstarter HyperV Module 2.4.38 450 Saturday, July 12, 2014 Approved
Boxstarter HyperV Module 2.4.35 489 Saturday, July 12, 2014 Approved
Boxstarter HyperV Module 2.4.32 498 Friday, July 11, 2014 Approved
Boxstarter HyperV Module 2.4.29 1259 Friday, July 4, 2014 Approved
Boxstarter HyperV Module 2.4.26 1017 Monday, June 23, 2014 Approved
Boxstarter HyperV Module 2.4.15 3015 Sunday, April 20, 2014 Approved
Boxstarter HyperV Module 2.4.12 509 Saturday, April 19, 2014 Approved
Boxstarter HyperV Module 2.4.4 791 Saturday, April 5, 2014 Approved
Boxstarter HyperV Module 2.4.0 487 Friday, April 4, 2014 Approved
Boxstarter HyperV Module 2.3.24 1875 Saturday, February 1, 2014 Approved
Boxstarter HyperV Module 2.3.15 591 Monday, January 27, 2014 Approved
Boxstarter HyperV Module 2.3.13 567 Saturday, January 25, 2014 Approved
Boxstarter HyperV Module 2.3.8 535 Thursday, January 23, 2014 Approved
Boxstarter HyperV Module 2.3.0 582 Monday, January 20, 2014 Approved
Boxstarter HyperV Module 2.2.78 684 Thursday, January 9, 2014 Approved
Boxstarter HyperV Module 2.2.59 783 Sunday, December 29, 2013 Approved
Boxstarter HyperV Module 2.2.23 857 Saturday, December 14, 2013 Approved
Boxstarter HyperV Module 2.2.16 485 Friday, December 13, 2013 Approved
Boxstarter HyperV Module 2.2.15 493 Friday, December 13, 2013 Approved
Boxstarter HyperV Module 2.2.12 513 Friday, December 13, 2013 Approved
BoxStarter HyperV Module 2.2.0 535 Thursday, December 12, 2013 Approved

  • Update vendored chocolatey to stable 0.10.5
  • Add required tags element to boxstarter.common nuspec
  • Fix Set-ExplorerOption argument names
  • Fix Nuspec dependencies to be exact
  • Update vendored chocolatey to stable 0.10.4
  • Randomize package names generated from script to avoid file locks
  • Update vendored Chocolatey to 0.10.4 beta
  • Add Icon toggling of task bar notifications in Set-TaskbarOptions
  • Fix registry key name in Set-TaskbarOptions on some Windows 10 versions
  • Fix Default of RebootOk in boxstarter shell
  • Stop powershell profile loading when in powershell v2
Discussion for the Boxstarter HyperV Module Package

Ground Rules:

  • This discussion is only about Boxstarter HyperV Module and the Boxstarter HyperV Module package. If you have feedback for Chocolatey, please contact the Google Group.
  • This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
  • The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
  • Tell us what you love about the package or Boxstarter HyperV Module, or tell us what needs improvement.
  • Share your experiences with the package, or extra configuration or gotchas that you've found.
  • If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.
comments powered by Disqus