Boxstarter HyperV Module

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

2.6.16 | Updated: 12/15/2015

Downloads:

527,402

Downloads of v 2.6.16:

526

Software Author(s):

  • Matt Wrock

Boxstarter HyperV Module 2.6.16

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

Some Checks Have Failed or Are Not Yet Complete

1 Test Pending and 1 Passing Test


Validation Testing Pending


Verification Testing Passed

Details

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:

>

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

1. Ensure you are set for organizational deployment

Please see the organizational deployment guide

  • 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://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. Enter your internal repository url

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

4. Choose your deployment method:


choco upgrade boxstarter.hyperv -y --source="'STEP 3 URL'" [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="'STEP 3 URL'" 
$exitCode = $LASTEXITCODE

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

Exit $exitCode

- name: Ensure boxstarter.hyperv installed
  win_chocolatey:
    name: boxstarter.hyperv
    state: present
    version: 2.6.16
    source: STEP 3 URL

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

Coming early 2020! Central Managment Reporting available now! More information...


chocolatey_package 'boxstarter.hyperv' do
  action    :install
  version  '2.6.16'
  source   'STEP 3 URL'
end

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


Chocolatey::Ensure-Package
(
    Name: boxstarter.hyperv,
    Version: 2.6.16,
    Source: STEP 3 URL
);

Requires Otter Chocolatey Extension. See docs at https://inedo.com/den/otter/chocolatey.


cChocoPackageInstaller boxstarter.hyperv
{
   Name     = 'boxstarter.hyperv'
   Ensure   = 'Present'
   Version  = '2.6.16'
   Source   = 'STEP 3 URL'
}

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


package { 'boxstarter.hyperv':
  provider => 'chocolatey',
  ensure   => '2.6.16',
  source   => 'STEP 3 URL',
}

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


salt '*' chocolatey.install boxstarter.hyperv version="2.6.16" source="STEP 3 URL"

See docs at https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.chocolatey.html.

5. If applicable - Chocolatey configuration/installation

See infrastructure management matrix for Chocolatey configuration elements and examples.

This package was approved as a trusted package on 12/15/2015.

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\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\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\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
        
            [email protected]{}
            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\chocolateyinstall.ps1
$tools = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
. (Join-Path $tools Setup.ps1)
try { 
    $ModuleName = (Get-ChildItem $tools | ?{ $_.PSIsContainer }).BaseName
    Install-Boxstarter "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" $ModuleName $env:chocolateyPackageParameters
} catch {
    write-output $_ | fl * -force
    throw $_.Exception
}
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\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
    }
}

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.

Version Downloads Last Updated Status
Boxstarter HyperV Module 2.11.0 63418 Wednesday, May 16, 2018 Approved
Boxstarter HyperV Module 2.10.3 50677 Thursday, August 31, 2017 Approved
Boxstarter HyperV Module 2.9.26 4954 Monday, June 19, 2017 Approved
Boxstarter HyperV Module 2.9.24 540 Sunday, June 18, 2017 Approved
Boxstarter HyperV Module 2.9.14 6532 Friday, May 5, 2017 Approved
Boxstarter HyperV Module 2.9.5 4445 Thursday, March 30, 2017 Approved
Boxstarter HyperV Module 2.9.2 935 Monday, March 27, 2017 Approved

  • Use internal function to download http gist scripts.
  • No longer vendors a legacy version of Chocolatey. Leverages the current beta Chocolatey library API for all Chocolatey interaction.
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