WindowsImageTools.psm1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#requires -Version 2 -Modules Storage
#requires -RunAsAdministrator

# Check for New-VHD
$VHDCmdlets = $true
if (-not (Get-Module -Name hyper-v -ListAvailable))
{
    $VHDCmdlets = $false
    Write-Warning -Message '[Module : WindowsImageTools] Hyper-V Module Not Installed: '
}
if ([environment]::OSVersion.Version.Major -ge 10 -and 
(Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Services).state -eq 'Disabled')
{
    $VHDCmdlets = $false
    Write-Warning -Message '[Module : WindowsImageTools] Hyper-v Services on windows 10 not installed'
}

if (-not ($VHDCmdlets))
{
    Write-Warning -Message '[Module : WindowsImageTools] *-VHD cmdlets not avalible '
    Write-Warning -Message ' Loading WIN2VHD Class'    
    . $PSScriptRoot\Functions\Wim2VHDClass.ps1
    Write-Warning -Message ' Windows Image Update function not loaded'
}

# Import Basic functions
. $PSScriptRoot\Functions\HelperFunctions.ps1
. $PSScriptRoot\Functions\Convert-Wim2VHD.ps1
. $PSScriptRoot\Functions\Initialize-VHDPartition.ps1
. $PSScriptRoot\Functions\Set-VHDPartition.ps1
. $PSScriptRoot\Functions\New-Unattend.ps1

if ($VHDCmdlets) #only import if depended functions avalible
{ 
    . $PSScriptRoot\Functions\New-WindowsImageToolsExample.ps1
    . $PSScriptRoot\Functions\Set-UpdateConfig.ps1
    . $PSScriptRoot\Functions\Add-UpdateImage.ps1
    . $PSScriptRoot\Functions\Update-WindowsImageWMF.ps1
    . $PSScriptRoot\Functions\Invoke-WindowsImageUpdate.ps1
    . $PSScriptRoot\Functions\Mount-VhdAndRunBlock.ps1
    . $PSScriptRoot\Functions\Invoke-CreateVmRunAndWait.ps1
    . $PSScriptRoot\Functions\Get-VhdPartitionStyle.ps1
}