Use toast messages to show status while deploying
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
a77e189730
commit
e89b41ab58
@ -77,6 +77,12 @@ If ($MissingProperties.Length -gt 0) {
|
|||||||
|
|
||||||
# Set hostname and description
|
# Set hostname and description
|
||||||
If ($Env:ComputerName -ne $ovfPropertyValues['guestinfo.hostname']) {
|
If ($Env:ComputerName -ne $ovfPropertyValues['guestinfo.hostname']) {
|
||||||
|
$NewToastSplat = @{
|
||||||
|
Title = 'OVF Properties'
|
||||||
|
Text = 'Configuring hostname and description...'
|
||||||
|
}
|
||||||
|
New-ToastNotification @NewToastSplat
|
||||||
|
|
||||||
$RenameComputerSplat = @{
|
$RenameComputerSplat = @{
|
||||||
NewName = $ovfPropertyValues['guestinfo.hostname']
|
NewName = $ovfPropertyValues['guestinfo.hostname']
|
||||||
Force = $True
|
Force = $True
|
||||||
@ -98,6 +104,12 @@ If ($Env:ComputerName -ne $ovfPropertyValues['guestinfo.hostname']) {
|
|||||||
|
|
||||||
# Configure network interface
|
# Configure network interface
|
||||||
If ((Get-WmiObject -Class 'Win32_NetworkAdapterConfiguration').IPAddress -NotContains $ovfPropertyValues['guestinfo.ipaddress']) {
|
If ((Get-WmiObject -Class 'Win32_NetworkAdapterConfiguration').IPAddress -NotContains $ovfPropertyValues['guestinfo.ipaddress']) {
|
||||||
|
$NewToastSplat = @{
|
||||||
|
Title = 'OVF Properties'
|
||||||
|
Text = 'Configuring network...'
|
||||||
|
}
|
||||||
|
New-ToastNotification @NewToastSplat
|
||||||
|
|
||||||
$NewNetIPAddressSplat = @{
|
$NewNetIPAddressSplat = @{
|
||||||
InterfaceAlias = (Get-NetAdapter).Name
|
InterfaceAlias = (Get-NetAdapter).Name
|
||||||
AddressFamily = 'IPv4'
|
AddressFamily = 'IPv4'
|
||||||
@ -152,6 +164,12 @@ If ((Get-WmiObject -Class 'Win32_NetworkAdapterConfiguration').IPAddress -NotCon
|
|||||||
|
|
||||||
# Promote to Domain Controller
|
# Promote to Domain Controller
|
||||||
If ((4,5) -NotContains (Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole) {
|
If ((4,5) -NotContains (Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole) {
|
||||||
|
$NewToastSplat = @{
|
||||||
|
Title = 'OVF Properties'
|
||||||
|
Text = 'Configuring local administrator password...'
|
||||||
|
}
|
||||||
|
New-ToastNotification @NewToastSplat
|
||||||
|
|
||||||
# Change password of built-in Administrator
|
# Change password of built-in Administrator
|
||||||
$BuiltinAdministrator = (Get-LocalUser | Where-Object {$_.SID -match '-500'})
|
$BuiltinAdministrator = (Get-LocalUser | Where-Object {$_.SID -match '-500'})
|
||||||
$ConvertToSecureStringSplat = @{
|
$ConvertToSecureStringSplat = @{
|
||||||
@ -170,6 +188,12 @@ If ((4,5) -NotContains (Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole)
|
|||||||
}
|
}
|
||||||
Set-LocalUser @SetLocalUserSplat
|
Set-LocalUser @SetLocalUserSplat
|
||||||
|
|
||||||
|
$NewToastSplat = @{
|
||||||
|
Title = 'OVF Properties'
|
||||||
|
Text = 'Promoting to Domain Controller...'
|
||||||
|
}
|
||||||
|
New-ToastNotification @NewToastSplat
|
||||||
|
|
||||||
$ResolveDNSNameSplat = @{
|
$ResolveDNSNameSplat = @{
|
||||||
Name = "_ldap._tcp.dc._msdcs.$($ovfPropertyValues['addsconfig.domainname'])"
|
Name = "_ldap._tcp.dc._msdcs.$($ovfPropertyValues['addsconfig.domainname'])"
|
||||||
ErrorAction = 'SilentlyContinue'
|
ErrorAction = 'SilentlyContinue'
|
||||||
@ -228,6 +252,12 @@ If ((4,5) -NotContains (Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole)
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Wait for Active Directory to become available
|
# Wait for Active Directory to become available
|
||||||
|
$NewToastSplat = @{
|
||||||
|
Title = 'OVF Properties'
|
||||||
|
Text = 'Waiting for Active Directory services...'
|
||||||
|
}
|
||||||
|
New-ToastNotification @NewToastSplat
|
||||||
|
|
||||||
$Timestamp, $TimeoutMinutes = (Get-Date), 15
|
$Timestamp, $TimeoutMinutes = (Get-Date), 15
|
||||||
Do {
|
Do {
|
||||||
If ($Timestamp.AddMinutes($TimeoutMinutes) -lt (Get-Date)) {
|
If ($Timestamp.AddMinutes($TimeoutMinutes) -lt (Get-Date)) {
|
||||||
@ -258,6 +288,12 @@ $GetItemSplat = @{
|
|||||||
}
|
}
|
||||||
Get-Item @GetItemSplat | ForEach-Object {
|
Get-Item @GetItemSplat | ForEach-Object {
|
||||||
Try {
|
Try {
|
||||||
|
$NewToastSplat = @{
|
||||||
|
Title = 'OVF Properties'
|
||||||
|
Text = "Running script: '$($_.FullName)'"
|
||||||
|
}
|
||||||
|
New-ToastNotification @NewToastSplat
|
||||||
|
|
||||||
$WriteEventLogSplat = @{
|
$WriteEventLogSplat = @{
|
||||||
LogName = 'Application'
|
LogName = 'Application'
|
||||||
Source = 'OVF-Properties'
|
Source = 'OVF-Properties'
|
||||||
@ -280,6 +316,12 @@ Get-Item @GetItemSplat | ForEach-Object {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$NewToastSplat = @{
|
||||||
|
Title = 'OVF Properties'
|
||||||
|
Text = "Sequence finished; ready for use!"
|
||||||
|
}
|
||||||
|
New-ToastNotification @NewToastSplat
|
||||||
|
|
||||||
$WriteEventLogSplat = @{
|
$WriteEventLogSplat = @{
|
||||||
LogName = 'Application'
|
LogName = 'Application'
|
||||||
Source = 'OVF-Properties'
|
Source = 'OVF-Properties'
|
||||||
@ -289,3 +331,26 @@ $WriteEventLogSplat = @{
|
|||||||
}
|
}
|
||||||
Write-EventLog @WriteEventLogSplat
|
Write-EventLog @WriteEventLogSplat
|
||||||
& schtasks.exe /Change /TN 'OVF-Properties' /DISABLE
|
& schtasks.exe /Change /TN 'OVF-Properties' /DISABLE
|
||||||
|
|
||||||
|
Function New-ToastNotification () {
|
||||||
|
Param(
|
||||||
|
[Parameter]
|
||||||
|
[string]$Stream = 'OVF Properties',
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[string]$Title,
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[string]$Text
|
||||||
|
)
|
||||||
|
|
||||||
|
$Template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText02)
|
||||||
|
|
||||||
|
$XML = [xml]$Template.GetXml()
|
||||||
|
$XML.SelectSingleNode("toast/visual/binding/text[@id='1']").InnerText = $Title
|
||||||
|
$XML.SelectSingleNode("toast/visual/binding/text[@id='2']").InnerText = $Text
|
||||||
|
|
||||||
|
$SerializedXml = New-Object Windows.Data.Xml.Dom.XmlDocument
|
||||||
|
$SerializedXml.LoadXml($XML.OuterXml)
|
||||||
|
|
||||||
|
$Notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($Stream)
|
||||||
|
$Notifier.Show([Windows.UI.Notifications.ToastNotification]::new($SerializedXml))
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user