Skip to content

Commit

Permalink
Fix target hyperv generation for vmware & msi auth check (#26211)
Browse files Browse the repository at this point in the history
Co-authored-by: Sam Lee <samlee3@microsoft.com>
  • Loading branch information
minhsuanlee and Sam Lee authored Oct 21, 2024
1 parent 1102f79 commit 5d33563
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,13 @@ function Initialize-AzMigrateHCIReplicationInfrastructure {
}

if (-not $userObject) {
$userObject = Get-AzADServicePrincipal -ApplicationID $context.Account.Id
if ($context.Account.Id.StartsWith("MSI@")) {
$hostname = $env:COMPUTERNAME
$userObject = Get-AzADServicePrincipal -DisplayName $hostname
}
else {
$userObject = Get-AzADServicePrincipal -ApplicationID $context.Account.Id
}
}

if (-not $userObject) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,14 @@ function New-AzMigrateHCIServerReplication {
$customProperties.TargetCpuCore = if ($HasTargetVMCPUCore) { $TargetVMCPUCore } else { $machine.NumberOfProcessorCore }
$customProperties.IsDynamicRam = if ($HasIsDynamicMemoryEnabled) { $isDynamicRamEnabled } else { $isSourceDynamicMemoryEnabled }

# Determine target VM Hyper-V Generation
if ($SiteType -eq $SiteTypes.HyperVSites) { # Hyper-V
$customProperties.HyperVGeneration = $machine.Generation
}
else { # VMware
$customProperties.HyperVGeneration = if ($machine.Firmware -eq "BIOS") { "1" } else { "2" }
}

# Validate TargetVMRam
if ($HasTargetVMRam) {
# TargetVMRam needs to be greater than 0
Expand Down

0 comments on commit 5d33563

Please sign in to comment.