Skip to content

Instantly share code, notes, and snippets.

@haukened
Last active July 25, 2024 03:34
Show Gist options
  • Save haukened/34308447a68f25b47db805320109c042 to your computer and use it in GitHub Desktop.
Save haukened/34308447a68f25b47db805320109c042 to your computer and use it in GitHub Desktop.
StackHCI Prep
$ErrorActionPreference = "Stop"
$share = "share"
$tmp_folder = "c:\Drivers"
$source = "prep"
# set our variables
$smbhost = ""
while ($smbhost -eq "") {
$smbhost = Read-Host "Domain controller IP address or hostname"
if ($smbhost -eq "") {
Write-Host "Error: Host cannot be empty"
}
}
# get the username and password to map the network drive
$cred = $host.ui.PromptForCredential("Admin Credentials", "Please enter credentials for \\$smbhost\$share", "", "NetBiosUserName")
# map the network drive
Write-Host "Mapping the network drive"
New-PSDrive -Name smb -PSProvider FileSystem -Root "\\$smbhost\$share" -Credential $cred
# create a temp folder
Write-Host "Creating the Drivers folder"
New-Item -Path $tmp_folder -ItemType Directory
# copy the files from the network drive to the temp folder
Write-Host "Copying the files from the network drive to the temp folder"
copy -Path "smb:\$source\*" -Destination $tmp_folder -Recurse
Write-Host "Driver installation completed"
# get the name of the zip file in the temp folder
Write-Host "Setting up Azure StackHCI Solution Builder Extensions"
$zip_file = Get-ChildItem -Path $tmp_folder -Filter "*.zip" -File
# make sure we only have one zip file
if ($zip_file.Count -ne 1) {
Write-Host "Error: Only one ZIP file allowed for Solution Builder Extensions."
exit 1
} else {
# extract the zip file
Write-Host "Extracting $zip_file.FullName to C:\SBE"
Expand-Archive -Path $zip_file.FullName -DestinationPath "C:\SBE"
Remove-Item -Path $zip_file.FullName
}
# now enable the hyper-v feature
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
# then reboot
Write-Host "Please Install Drivers in C:\Drivers and reboot the server"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment