Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions hyperv-tools/Convert-WindowsImage/Convert-WindowsImage.psm1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<#
This is PS Module the new long-term home for Convert-WindowsImage and sister functions.
This is PS Module - the new long-term home for Convert-WindowsImage and sister functions.

Copyright (c) Microsoft Corporation. All rights reserved.

Expand Down Expand Up @@ -671,15 +671,15 @@ Convert-WindowsImage
return $parameterDictionary
}

Begin
Begin
{

Set-StrictMode -version 3
$Module = Import-ModuleEx -Name "Dism"
$Module = Import-ModuleEx -Name "Storage"

#region Constants and Pseudo-Constants

# Name of the script, obviously.
$scriptName = "Convert-WindowsImage"

Expand Down Expand Up @@ -734,9 +734,19 @@ Convert-WindowsImage
{
Try
{
$hyperVEnabled =
$OSVersion = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName).ProductName
If ($OSVersion -like "Windows Server*")
{
$hyperVEnabled =
[bool]( Get-WindowsOptionalFeature -Online -FeatureName "Microsoft-Hyper-V" -Verbose:$False ).State -and
[bool]( Get-WindowsOptionalFeature -Online -FeatureName "Microsoft-Hyper-V-Management-PowerShell" -Verbose:$False ).State
}
Else
{
$hyperVEnabled =
[bool]( Get-WindowsOptionalFeature -Online -FeatureName "Microsoft-Hyper-V-Services" -Verbose:$False ).State -and
[bool]( Get-WindowsOptionalFeature -Online -FeatureName "Microsoft-Hyper-V-Management-PowerShell" -Verbose:$False ).State
}
}
Catch
{
Expand Down Expand Up @@ -2340,7 +2350,7 @@ You can use the fields below to configure the VHD or VHDX that you want to creat
$DismountDiskImage = Dismount-DiskImage -ImagePath $VhdPath -PassThru
}
Else {
$DismountDiskImage = Dismount-DiskImage -ImagePath $VhdPath
$DismountDiskImage = Dismount-DiskImage -ImagePath $VhdPath
}
}

Expand Down Expand Up @@ -2413,7 +2423,7 @@ You can use the fields below to configure the VHD or VHDX that you want to creat
$DismountDiskImage = Dismount-DiskImage -ImagePath $VhdPath -PassThru
}
Else {
$DismountDiskImage = Dismount-DiskImage -ImagePath $VhdPath
$DismountDiskImage = Dismount-DiskImage -ImagePath $VhdPath
}
}
}
Expand All @@ -2426,7 +2436,7 @@ You can use the fields below to configure the VHD or VHDX that you want to creat
$DismountDiskImage = Dismount-DiskImage -ImagePath $IsoPath -PassThru
}
Else {
$DismountDiskImage = Dismount-DiskImage -ImagePath $IsoPath
$DismountDiskImage = Dismount-DiskImage -ImagePath $IsoPath
}
}

Expand All @@ -2447,7 +2457,7 @@ You can use the fields below to configure the VHD or VHDX that you want to creat
}
}
}
End
End
{

If ($Passthru)
Expand Down