Skip to content

Commit 0d27106

Browse files
shuklaprakhar415Prakhar ShuklaYanaXu
authored
Using fully qualified computer name and adding warning message for solution upgrade (#28109)
Co-authored-by: Prakhar Shukla <[email protected]> Co-authored-by: Yan Xu <[email protected]>
1 parent 3d63335 commit 0d27106

File tree

2 files changed

+64
-7
lines changed

2 files changed

+64
-7
lines changed

src/StackHCI/StackHCI.Autorest/custom/stackhci.ps1

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ $StartingCloudManagementMessage = "Starting Cloud Management agent."
136136
$RemoteSupportConsentText = "`r`n`r`nBy approving this request, the Microsoft support organization or the Azure engineering team supporting this feature ('Microsoft Support Engineer') will be given direct access to your device for troubleshooting purposes and/or resolving the technical issue described in the Microsoft support case. `r`n`r`nDuring a remote support session, a Microsoft Support Engineer may need to collect logs. By enabling remote support, you have agreed to a diagnostic logs collection by Microsoft Support Engineer to address a support case You also acknowledge and consent to the upload and retention of those logs in an Azure storage account managed and controlled by Microsoft. These logs may be accessed by Microsoft in the context of a support case and to improve the health of Azure Stack HCI. `r`n`r`nThe data will be used only to troubleshoot failures that are subject to a support ticket, and will not be used for marketing, advertising, or any other commercial purposes without your consent. The data may be retained for up to ninety (90) days and will be handled following our standard privacy practices (https://privacy.microsoft.com/en-US/). Any data previously collected with your consent will not be affected by the revocation of your permission."
137137

138138
$UpgradeOSMessage = "Your system is running Azure Local, version 22H2, and will no longer receive security updates and support after May 31, 2025. To continue receiving security updates and support, you must upgrade your operating system. Visit https://aka.ms/azlocal-os-upgrade to learn more."
139+
$UpgradeToSolutionMessage = "Your system is not running the Azure Local solution. Install the solution upgrade to get the latest features and capabilities. Visit https://aka.ms/azlocal-solution-upgrade to learn more."
139140

140141
$AlreadyLoggedFlag = "Already Logged"
141142
#endregion
@@ -436,13 +437,14 @@ Function Write-NodeEventLog{
436437
if($IsManagementNode)
437438
{
438439
Write-VerboseLog ("Connecting from management node")
440+
$ComputerNameWithDNSSuffix = $ComputerName + '.' + (Get-WmiObject Win32_ComputerSystem).Domain
439441
if($Null -eq $Credentials)
440442
{
441-
$session = New-PSSession -ComputerName $ComputerName
443+
$session = New-PSSession -ComputerName $ComputerNameWithDNSSuffix
442444
}
443445
else
444446
{
445-
$session = New-PSSession -ComputerName $ComputerName -Credential $Credentials
447+
$session = New-PSSession -ComputerName $ComputerNameWithDNSSuffix -Credential $Credentials
446448
}
447449
}
448450
else
@@ -518,6 +520,51 @@ function Confirm-UserAcknowledgmentToUpgradeOS {
518520
}
519521
}
520522

523+
function Confirm-UserAcknowledgmentUpgradeToSolution {
524+
[CmdletBinding()]
525+
param(
526+
[Parameter(Mandatory=$true)]
527+
[System.Management.Automation.Runspaces.PSSession]
528+
$ClusterNodeSession
529+
)
530+
531+
$osVersionDetectoid = { $displayVersion = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion").DisplayVersion; $buildNumber = (Get-CimInstance -ClassName CIM_OperatingSystem).BuildNumber; New-Object -TypeName PSObject -Property @{'DisplayVersion'=$displayVersion; 'BuildNumber'=$buildNumber} }
532+
$osVersionInfo = Invoke-Command -Session $clusterNodeSession -ScriptBlock $osVersionDetectoid
533+
534+
# Combined script block to check both deployment and ECE service status
535+
$solutionDetectoid = {
536+
# Check deployment registry key
537+
$deploymentRegKey = Get-ItemProperty -Path "HKLM:\Software\Microsoft\AzureStackStampInformation" -Name "DeployType" -ErrorAction SilentlyContinue
538+
$hasDeploymentReg = $false
539+
if ($null -ne $deploymentRegKey) {
540+
$deployType = $deploymentRegKey.DeployType
541+
$hasDeploymentReg = ($deployType -ieq "Deployment")
542+
}
543+
544+
# Check ECE service
545+
$eceWindowsService = Get-Service | Where-Object Name -in @("Azure Stack HCI Orchestrator Service", "ECE Windows Service")
546+
$hasECEService = ($null -ne $eceWindowsService)
547+
548+
New-Object -TypeName PSObject -Property @{
549+
'HasDeploymentReg' = $hasDeploymentReg
550+
'HasECEService' = $hasECEService
551+
}
552+
}
553+
554+
# Warning - if the OS version is 23H2 or later with no solution running
555+
if (([Int]::Parse($osVersionInfo.BuildNumber) -ge $23H2BuildNumber))
556+
{
557+
Write-VerboseLog "Checking solution deployment status."
558+
$solutionStatus = Invoke-Command -Session $ClusterNodeSession -ScriptBlock $solutionDetectoid
559+
560+
# If neither deployment registry key nor ECE service indicates solution is running
561+
if (-not $solutionStatus.HasDeploymentReg -and -not $solutionStatus.HasECEService)
562+
{
563+
Write-Warning $UpgradeToSolutionMessage
564+
}
565+
}
566+
}
567+
521568
$CheckNodeArcRegistrationStateScriptBlock = {
522569
if(Test-Path -Path "C:\Program Files\AzureConnectedMachineAgent\azcmagent.exe")
523570
{
@@ -2268,13 +2315,14 @@ param(
22682315

22692316
if($IsManagementNode)
22702317
{
2318+
$ComputerNameWithDNSSuffix = "$ComputerName.$ClusterDNSSuffix"
22712319
if($Credential -eq $Null)
22722320
{
2273-
$session = New-PSSession -ComputerName $ComputerName
2321+
$session = New-PSSession -ComputerName $ComputerNameWithDNSSuffix
22742322
}
22752323
else
22762324
{
2277-
$session = New-PSSession -ComputerName $ComputerName -Credential $Credential
2325+
$session = New-PSSession -ComputerName $ComputerNameWithDNSSuffix -Credential $Credential
22782326
}
22792327
}
22802328
else
@@ -2516,13 +2564,14 @@ param(
25162564
if($IsManagementNode)
25172565
{
25182566
Write-VerboseLog ("connecting via Management node")
2567+
$ComputerNameWithDNSSuffix = "$ComputerName.$ClusterDNSSuffix"
25192568
if($Credential -eq $Null)
25202569
{
2521-
$session = New-PSSession -ComputerName $ComputerName
2570+
$session = New-PSSession -ComputerName $ComputerNameWithDNSSuffix
25222571
}
25232572
else
25242573
{
2525-
$session = New-PSSession -ComputerName $ComputerName -Credential $Credential
2574+
$session = New-PSSession -ComputerName $ComputerNameWithDNSSuffix -Credential $Credential
25262575
}
25272576
}
25282577
else
@@ -2946,6 +2995,11 @@ param(
29462995

29472996
Confirm-UserAcknowledgmentToUpgradeOS -ClusterNodeSession $clusterNodeSession
29482997

2998+
if ($RepairRegistration -eq $true)
2999+
{
3000+
Confirm-UserAcknowledgmentUpgradeToSolution -ClusterNodeSession $clusterNodeSession
3001+
}
3002+
29493003
$global:HCILogsDirectory = Setup-Logging -LogsDirectory $LogsDirectory -LogFilePrefix "RegisterHCI" -DebugEnabled ($DebugPreference -ne "SilentlyContinue") -IsClusterRegistered $IsClusterRegistered -ClusterNodeSession $clusterNodeSession
29503004

29513005
if($IsClusterRegistered -and !([string]::IsNullOrEmpty($LogsDirectory)))
@@ -4195,6 +4249,7 @@ param(
41954249
$regContext, $IsClusterRegistered, $clusterNodeSession, $_ = Get-SetupLoggingDetails -ComputerName $ComputerName -Credential $Credential -IsManagementNode $isManagementNode
41964250

41974251
Confirm-UserAcknowledgmentToUpgradeOS -ClusterNodeSession $clusterNodeSession
4252+
Confirm-UserAcknowledgmentUpgradeToSolution -ClusterNodeSession $clusterNodeSession
41984253

41994254
$global:HCILogsDirectory = Setup-Logging -LogFilePrefix "UnregisterHCI" -DebugEnabled ($DebugPreference -ne "SilentlyContinue") -IsClusterRegistered $IsClusterRegistered -ClusterNodeSession $clusterNodeSession
42004255

@@ -4672,7 +4727,8 @@ function Get-SetupLoggingDetails
46724727

46734728
if($isManagementNode)
46744729
{
4675-
$nodeSessionParams.Add('ComputerName', $ComputerName)
4730+
$ComputerNameWithDNSSuffix = $ComputerName + '.' + (Get-WmiObject Win32_ComputerSystem).Domain
4731+
$nodeSessionParams.Add('ComputerName', $ComputerNameWithDNSSuffix)
46764732

46774733
if($null -ne $Credential)
46784734
{

src/StackHCI/StackHCI/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Used fully qualified computer name and added warning for user to upgrade to solution.
2122

2223
## Version 2.6.0
2324
* Added EOL Message for 22H2

0 commit comments

Comments
 (0)