You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Only check the disk where CloudBuilder.vhdx locates and ensure it is
not virtual disk;
2. Refine order of configuring steps to avoid reboot while preparation
fails;
@@ -10,48 +10,48 @@ Prepare the host to boot from the Azure Stack virtual harddisk.
10
10
.DESCRIPTION
11
11
12
12
PrepareBootFromVHD updates the boot configuration with an Azure Stack entry.
13
-
It will verify if the disk that hosts the cloudbuilder.vhdx contains the required free disk space, Optionally copy drivers and an unattend.xml that does not require KVM access.
13
+
It will verify if the disk that hosts the CloudBuilder.vhdx contains the required free disk space, Optionally copy drivers and an unattend.xml that does not require KVM access.
14
14
15
15
16
16
.PARAMETER CloudBuilderDiskPath
17
17
18
-
Path to the cloudbuilder.vhdx. This parameter is mandatory.
18
+
Path to the CloudBuilder.vhdx. This parameter is mandatory.
19
19
20
20
.PARAMETER DriverPath
21
21
22
-
This optional parameter allows you to add additional drivers for the host in the virtual harddisk. Specify the path that contains the drivers and all its content wil be copied the to cloudbuilder.vhdx.
22
+
This optional parameter allows you to add additional drivers for the host in the virtual harddisk. Specify the path that contains the drivers and all its content wil be copied the to CloudBuilder.vhdx.
23
23
24
24
.PARAMETER ApplyUnattend
25
25
26
26
ApplyUnattend is a switch parameter. If this parameter is specified, the configuration of the Operating System is automated.
27
-
After the host reboots to the cloudbuilder.vhdx, the Operating System is automatically configured and you can connect to the host with RDP without KVM requirement.
27
+
After the host reboots to the CloudBuilder.vhdx, the Operating System is automatically configured and you can connect to the host with RDP without KVM requirement.
28
28
If this parameter is specified, you will be prompted for an local administrator password that is used for the unattend.xml.
29
-
If this parameter is not specified, a minimal unattend.xml is used to enable Remote Desktop. KVM is required to configure the Operating System when booting from cloudbuilder.vhdx for the first time.
29
+
If this parameter is not specified, a minimal unattend.xml is used to enable Remote Desktop. KVM is required to configure the Operating System when booting from vs.vhdx for the first time.
30
30
31
31
.PARAMETER AdminPassword
32
32
33
33
The AdminPassword parameter is only used when the ApplyUnnatend parameter is set. The Password requires minimal 6 characters.
34
34
35
35
.EXAMPLE
36
36
37
-
Prepare the host to boot from cloudbuilder.vhdx. This requires KVM access to the host for configuring the Operating System.
You will need at least (120GB - Size of the cloudbuilder.vhdx file) of free disk space on the disk that contains the CloudBuilder.vhdx.
47
+
You will need at least (120GB - Size of the CloudBuilder.vhdx file) of free disk space on the disk that contains the CloudBuilder.vhdx.
48
48
49
49
#>
50
50
51
51
[CmdletBinding()]
52
52
Param (
53
53
[Parameter(Mandatory=$true)]
54
-
$CloudBuilderDiskPath,
54
+
[String]$CloudBuilderDiskPath,
55
55
56
56
[Parameter(Mandatory=$false)]
57
57
[string[]]$DriverPath=$null,
@@ -66,123 +66,155 @@ Param (
66
66
[String]$VHDLanguage="en-US"
67
67
)
68
68
69
+
$error.Clear()
70
+
69
71
#region Allow for manual override of PS (replace $PSScriptRoot with a path)
70
-
$currentPath=$PSScriptRoot
71
-
# $currentPath = 'C:\ForRTMBuilds'
72
-
# $CloudBuilderDiskPath = 'C:\CloudBuilder.vhdx'
72
+
$currentPath=$PSScriptRoot
73
+
# $currentPath = 'C:\ForRTMBuilds'
74
+
# $CloudBuilderDiskPath = 'C:\CloudBuilder.vhdx'
73
75
#endregion
74
76
75
-
if (!(Test-Path-Path $CloudBuilderDiskPath))
76
-
{
77
-
Write-Host"Can't find cloudbuilder vhd"
77
+
#region Check parameters and prerequisites
78
+
79
+
if (-not (Test-Path-Path $CloudBuilderDiskPath)) {
80
+
Write-Host"Can't find CloudBuilder.vhdx."-ForegroundColor Red
78
81
Exit
79
-
}
82
+
}
80
83
81
-
if ((Get-DiskImage-ImagePath $CloudBuilderDiskPath).Attached)
82
-
{
83
-
Write-Host"VHD Already mounted"
84
+
if ((Get-DiskImage-ImagePath $CloudBuilderDiskPath).Attached) {
85
+
Write-Host"CloudBuilder.vhdx is already mounted."-ForegroundColor Red
84
86
Exit
85
-
}
87
+
}
86
88
87
-
if ((get-disk|where {$_.isboot-eq$true}).Model -match'Virtual Disk')
88
-
{
89
-
Write-Host"The server is currently already booted from a virtual hard disk, to boot the server from the CloudBuilder.vhdx you will need to run this script on an Operating System that is installed on the physical disk of this server."
89
+
# Validate the CloudBuilder.vhdx is in a physical disk
Write-Host"The CloudBuilder.vhdx is in a virtual hard disk, please place it in a physical disk."-ForegroundColor Red
100
+
Exit
91
101
}
102
+
}
92
103
93
-
if (($ApplyUnattend) -and (!($AdminPassword)))
94
-
{
95
-
while ($SecureAdminPassword.Length-le6) {
96
-
[System.Security.SecureString]$SecureAdminPassword=read-host'Password for the local administrator account of the Azure Stack host. Requires 6 characters minimum'-AsSecureString
Write-Host"-ApplyUnattend is specified, but unattend_NoKVM.xml is not downloaded to the same directory of this script."-ForegroundColor Red
109
+
Exit
110
+
}
111
+
112
+
# Check Admin password for unattend
113
+
if(-not$AdminPassword) {
114
+
while ($SecureAdminPassword.Length-le6) {
115
+
[System.Security.SecureString]$SecureAdminPassword=read-host'Password for the local administrator account of the Azure Stack host. Requires 6 characters minimum'-AsSecureString
if (($cbDiskSizeReq-$cbDiskSize) -ge$cbhDiskRemaining)
111
-
{
129
+
if (($cbDiskSizeReq-$cbDiskSize) -ge$cbhDiskRemaining) {
112
130
Write-Host'Error: Insufficient disk space'-BackgroundColor Red
113
131
Write-Host'Cloudbuilder.vhdx is placed on' ((Get-Item$CloudBuilderDiskPath).PSDrive.Root) -ForegroundColor Yellow
114
132
Write-Host'When you boot from CloudBuilder.vhdx the virtual hard disk will be expanded to its full size of'$cbDiskSizeReq'GB.'-ForegroundColor Yellow
115
133
Write-Host ((Get-Item$CloudBuilderDiskPath).PSDrive.Root) 'does not contain enough free space.'-ForegroundColor Yellow
116
134
Write-Host'You need' ($cbDiskSizeReq-$cbDiskSize) 'GB of free disk space for a succesfull boot from CloudBuilder.vhdx, but' ((Get-Item$CloudBuilderDiskPath).PSDrive.Root) 'only has'$cbhDiskRemaining'GB remaining.'-ForegroundColor Yellow
117
135
Write-Host'Ensure Cloudbuilder.vhdx is placed on a local disk that contains enough free space and rerun this script.'-ForegroundColor Yellow
0 commit comments