SDMenus.psm1
Function New-SDMainMenu { Write-Host "" Write-Host "Welcome to the Stack Deployment Tool" Write-Host "" Write-Host "1) Settings" Write-Host "2) Server Information" Write-Host "3) Start Deployment" Write-Host "4) Run Specific Automation Steps" Write-Host "5) Exit" Write-Host "" $option = Read-Host -Prompt "Enter Option" #Cast string option to an Int32 $option = [int]$option if ($option -eq 1) { Clear-Host New-SDSettingsMenu } if ($option -eq 2) { Clear-Host New-SDSRVInfo } if ($option -eq 3) { Clear-Host Start-SDInstall } if ($option -eq 4) { Clear-Host New-SDSpecificMenu } if ($option -eq 5) { Clear-Host } } Function New-SDSettingsMenu { Write-Host "" Write-Host "Settings" Write-Host "" Write-Host "1) Domain Name" Write-Host "2) Site Number" Write-Host "3) Return to Main Menu" Write-Host "" $option = Read-Host -Prompt "Enter Option" #Cast string option to an Int32 $option = [int]$option if ($option -eq 1) { Clear-Host Write-Host "There Current Domain Name is: " ($null -eq $config.config.DomainName ? "Not Set" : $config.config.DomainName) Write-Host "" do { $i = 0 Try { [ValidatePattern('^(?i)(yes|no|y|n)$')]$change = Read-host 'Would you like to Change (Y/N)' -ErrorAction Stop } Catch { Write-Error -Message "You must enter Y for Yes and N for No" continue } break }until($i -eq 1) if ($change -match "^(yes|y)$") { Clear-Host $domainName = Read-Host "Enter Domain Name" Set-SDConfig -Key DomainName -Value $domainName #Refresh Config in memory Get-SDConfig Write-Host "The new Domain Name is: " ($null -eq $config.config.DomainName ? "Not Set" : $config.config.DomainName) Write-Host "" Read-Host "Press any key to continue" Clear-Host New-SDSettingsMenu } if ($change -match "^(no|n)$" ) { Clear-Host New-SDSettingsMenu } } if ($option -eq 2) { Clear-Host Write-Host "There Current Site Number is: " ($null -eq $config.config.SiteNumber ? "Not Set" : $config.config.SiteNumber) Write-Host "" do { $i = 0 Try { [ValidatePattern('^(?i)(yes|no|n|y)$')]$change = read-host 'Would you like to Change (Y/N)' -ErrorAction Stop } Catch { Write-Error -Message "You must enter Y for yes and N for no" continue } break }until($i -eq 1) if ($change -match "^(yes|y)$") { Clear-Host $siteNumber = Read-Host "Enter Site Number" Set-SDConfig -key SiteNumber -value $siteNumber #refresh Config in memory Get-SDConfig Write-Host "The new Site Number is: " ($null -eq $config.config.SiteNumber ? "Not Set" : $config.config.SiteNumber) Write-Host "" Read-Host "Press any key to continue" Clear-Host New-SDSettingsMenu } if ($change -match "^(no|n)$") { Clear-Host New-SDSettingsMenu } } if ($option -eq 3) { Clear-Host New-SDMainMenu } } Function New-SDSpecificMenu { <# This function is used to print a menu then execute specifi automation tasks in the event you need to rerun a task or something failed. v1.0 - JUL-16-2022 - Inital #> Write-Host "" Write-Host "Specific Automation Tasks" Write-Host "" Write-Host "1) Configure Cisco IMC Settings" Write-Host "2) Deploy vCenter" Write-Host "3) Configure vCenter Settings" Write-Host "4) Add vSphere Hosts to Cluster or DataCenter" Write-Host "5) Configure vSphere Hosts" Write-Host "6) Deploy vSAN Witness Host" Write-Host "7) Configure Streched Cluster" Write-Host "8) Return to Main Menu" Write-Host "" $option = Read-Host -Prompt "Enter Option" #Cast string option to an Int32 $option = [int]$option if ($option -match "[1-8]") { switch ($option) { 1 { Clear-Host Start-SDInstall -Step 1 -StopAfterStep 1 } 2 { Clear-Host Start-SDInstall -Step 2 -StopAfterStep 1 } 3 { Clear-Host Start-SDInstall -Step 3 -StopAfterStep 1 } 4 { Clear-Host Start-SDInstall -Step 4 -StopAfterStep 1 } 5 { Clear-Host Start-SDInstall -Step 5 -StopAfterStep 1 } 6 { Clear-Host Start-SDInstall -Step 6 -StopAfterStep 1 } 7 { Clear-Host Start-SDInstall -Step 7 -StopAfterStep 1 } 8 { Clear-Host New-SDMainMenu } Default {} } } else { Write-Warning -Message "Must enter a number between 1 and 7" Start-Sleep -Seconds 3 CLear-Host New-SDSpecificMenu } } Function New-SDSRVInfo { Write-Host "" Write-Host "Server Information Menu" Write-Host "" Write-Host "1) Manually add Servers" Write-Host "2) Import from File" Write-Host "3) Get Current Server Info" Write-Host "4) Go back to Main Menu" Write-Host "" $option = Read-Host -Prompt "Enter Option" if ($option -eq 1) { Clear-Host Add-SDServerInfo } if ($option -eq 2) { Clear-Host Import-SDServerInfo } if ($option -eq 3) { Clear-Host Get-SDServerInfo } if ($option -eq 4) { Clear-Host New-SDMainMenu } } #Export Functions Export-ModuleMember -Function New-SDMainMenu Export-ModuleMember -Function New-SDSettingsMenu Export-ModuleMember -Function New-SDSpecificMenu Export-ModuleMember -Function New-SDSRVInfo |