Payloadscripts act on 'deployment.type'
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
bd0423e701
commit
09f36ea66a
@ -30,22 +30,44 @@ foreach ($ovfProperty in $ovfProperties) {
|
||||
}
|
||||
|
||||
# Check for mandatory values
|
||||
If (!($ovfPropertyValues['guestinfo.hostname'] -and
|
||||
$ovfPropertyValues['guestinfo.ipaddress'] -and
|
||||
$ovfPropertyValues['guestinfo.dnsserver'] -and
|
||||
$ovfPropertyValues['guestinfo.prefixlength'] -and
|
||||
$ovfPropertyValues['guestinfo.gateway'] -and
|
||||
$ovfPropertyValues['addsconfig.domainname'] -and
|
||||
$ovfPropertyValues['addsconfig.netbiosname'] -and
|
||||
$ovfPropertyValues['addsconfig.administratorpw'] -and
|
||||
$ovfPropertyValues['addsconfig.safemodepw'])) {
|
||||
Switch ($ovfPropertyValues['deployment.type']) {
|
||||
'primary' {
|
||||
$MandatoryProperties, $MissingProperties = @('guestinfo.hostname', 'guestinfo.ipaddress', 'guestinfo.prefixlength', 'guestinfo.gateway', 'addsconfig.domainname', 'addsconfig.netbiosname', 'addsconfig.administratorpw', 'addsconfig.safemodepw', 'addsconfig.ntpserver'), @()
|
||||
}
|
||||
'secondary' {
|
||||
$MandatoryProperties, $MissingProperties = @('guestinfo.hostname', 'guestinfo.ipaddress', 'guestinfo.prefixlength', 'guestinfo.dnsserver', 'guestinfo.gateway', 'addsconfig.domainname', 'addsconfig.netbiosname', 'addsconfig.administratorpw', 'addsconfig.safemodepw', 'dhcpconfig.startip', 'dhcpconfig.endip', 'dhcpconfig.subnetmask', 'dhcpconfig.gateway', 'dhcpconfig.leaseduration'), @()
|
||||
}
|
||||
'standalone' {
|
||||
$MandatoryProperties, $MissingProperties = @('guestinfo.hostname', 'guestinfo.ipaddress', 'guestinfo.prefixlength', 'guestinfo.gateway', 'addsconfig.domainname', 'addsconfig.netbiosname', 'addsconfig.administratorpw', 'addsconfig.safemodepw', 'addsconfig.ntpserver', 'dhcpconfig.startip', 'dhcpconfig.endip', 'dhcpconfig.subnetmask', 'dhcpconfig.gateway', 'dhcpconfig.leaseduration'), @()
|
||||
}
|
||||
default {
|
||||
# Mandatory values missing, cannot provision.
|
||||
$WriteEventLogSplat = @{
|
||||
LogName = 'Application'
|
||||
Source = 'OVF-Properties'
|
||||
EntryType = 'Error'
|
||||
EventID = 66
|
||||
Message = 'Mandatory values missing, cannot provision.'
|
||||
Message = "Unexpected or no value set for property 'deployment.type', cannot provision."
|
||||
}
|
||||
Write-EventLog @WriteEventLogSplat
|
||||
& schtasks.exe /Change /TN 'OVF-Properties' /DISABLE
|
||||
Stop-Computer -Force
|
||||
Exit
|
||||
}
|
||||
}
|
||||
ForEach ($Property in $MandatoryProperties) {
|
||||
If (!$ovfPropertyValues[$Property]) {
|
||||
$MissingProperties += $Property
|
||||
}
|
||||
}
|
||||
If ($MissingProperties.Length -gt 0) {
|
||||
# Mandatory values missing, cannot provision.
|
||||
$WriteEventLogSplat = @{
|
||||
LogName = 'Application'
|
||||
Source = 'OVF-Properties'
|
||||
EntryType = 'Error'
|
||||
EventID = 66
|
||||
Message = "Missing values for mandatory properties $(($MissingProperties | ForEach-Object {'{0}' -f $_}) -join ', '), cannot provision."
|
||||
}
|
||||
Write-EventLog @WriteEventLogSplat
|
||||
& schtasks.exe /Change /TN 'OVF-Properties' /DISABLE
|
||||
|
@ -4,8 +4,8 @@ Param(
|
||||
[hashtable]$Parameter
|
||||
)
|
||||
|
||||
# Only executed on primary Domain Controller
|
||||
If ((Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole -eq 5) {
|
||||
# Only executed on primary or standalone Domain Controller
|
||||
If (@('primary','standalone') -contains $Parameter['deployment.type']) {
|
||||
$GetContentSplat = @{
|
||||
Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', ".csv")
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ Param(
|
||||
[hashtable]$Parameter
|
||||
)
|
||||
|
||||
# Only executed on primary Domain Controller
|
||||
If ((Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole -eq 5) {
|
||||
# Only executed on primary or standalone Domain Controller
|
||||
If (@('primary','standalone') -contains $Parameter['deployment.type']) {
|
||||
$GetContentSplat = @{
|
||||
Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', ".csv")
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ Param(
|
||||
[hashtable]$Parameter
|
||||
)
|
||||
|
||||
# Only executed on primary Domain Controller
|
||||
If ((Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole -eq 5) {
|
||||
# Only executed on primary or standalone Domain Controller
|
||||
If (@('primary','standalone') -contains $Parameter['deployment.type']) {
|
||||
$GetContentSplat = @{
|
||||
Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', ".csv")
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ Param(
|
||||
[hashtable]$Parameter
|
||||
)
|
||||
|
||||
# Only executed on primary Domain Controller
|
||||
If ((Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole -eq 5) {
|
||||
# Only executed on primary or standalone Domain Controller
|
||||
If (@('primary','standalone') -contains $Parameter['deployment.type']) {
|
||||
$PSDrive = Get-PSDrive -Name 'AD'
|
||||
If ([boolean]$PSDrive -eq $False) {
|
||||
$NewPSDriveSplat = @{
|
||||
|
@ -4,8 +4,8 @@ Param(
|
||||
[hashtable]$Parameter
|
||||
)
|
||||
|
||||
# Only executed on primary Domain Controller
|
||||
If ((Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole -eq 5) {
|
||||
# Only executed on primary or standalone Domain Controller
|
||||
If (@('primary','standalone') -contains $Parameter['deployment.type']) {
|
||||
$GetContentSplat = @{
|
||||
Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', '.yml')
|
||||
Raw = $true
|
||||
|
@ -4,8 +4,8 @@ Param(
|
||||
[hashtable]$Parameter
|
||||
)
|
||||
|
||||
# Only executed on secondary Domain Controller
|
||||
If ((Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole -eq 4) {
|
||||
# Only executed on secondary or standalone Domain Controller
|
||||
If (@('secondary','standalone') -contains $Parameter['deployment.type']) {
|
||||
$AddDhcpServerv4ScopeSplat = @{
|
||||
Name = 'Default DHCP scope'
|
||||
StartRange = [ipaddress]$Parameter['dhcpconfig.startip']
|
||||
|
@ -5,7 +5,7 @@ Param(
|
||||
)
|
||||
|
||||
# Only executed on secondary Domain Controller
|
||||
If ((Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole -eq 4) {
|
||||
If ($Parameter['deployment.type'] -eq 'secondary') {
|
||||
# Wait for secondary DHCP server to be registered in DNS
|
||||
$Timestamp, $TimeoutMinutes = (Get-Date), 5
|
||||
Do {
|
||||
|
@ -4,8 +4,8 @@ Param(
|
||||
[hashtable]$Parameter
|
||||
)
|
||||
|
||||
# Only executed on secondary Domain Controller
|
||||
If ((Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole -eq 4) {
|
||||
# Only executed on secondary or standalone Domain Controller
|
||||
If (@('secondary','standalone') -contains $Parameter['deployment.type']) {
|
||||
$GetContentSplat = @{
|
||||
Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', '.yml')
|
||||
Raw = $True
|
||||
|
@ -4,8 +4,8 @@ Param(
|
||||
[hashtable]$Parameter
|
||||
)
|
||||
|
||||
# Only executed on primary Domain Controller
|
||||
If ((Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole -eq 5) {
|
||||
# Only executed on primary or standalone Domain Controller
|
||||
If (@('primary','standalone') -contains $Parameter['deployment.type']) {
|
||||
$GetContentSplat = @{
|
||||
Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', '.yml')
|
||||
Raw = $True
|
||||
|
@ -4,8 +4,8 @@ Param(
|
||||
[hashtable]$Parameter
|
||||
)
|
||||
|
||||
# Only executed on primary Domain Controller
|
||||
If ((Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole -eq 5) {
|
||||
# Only executed on primary or standalone Domain Controller
|
||||
If (@('primary','standalone') -contains $Parameter['deployment.type']) {
|
||||
$NewPSSessionSplat = @{
|
||||
ComputerName = $Parameter['guestinfo.hostname']
|
||||
Credential = New-Object System.Management.Automation.PSCredential(
|
||||
|
@ -4,8 +4,8 @@ Param(
|
||||
[hashtable]$Parameter
|
||||
)
|
||||
|
||||
# Only executed on primary Domain Controller
|
||||
If ((Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole -eq 5) {
|
||||
# Only executed on primary or standalone Domain Controller
|
||||
If (@('primary','standalone') -contains $Parameter['deployment.type']) {
|
||||
$PSDrive = Get-PSDrive -Name 'AD'
|
||||
If ([boolean]$PSDrive -eq $False) {
|
||||
$NewPSDriveSplat = @{
|
||||
|
@ -4,8 +4,8 @@ Param(
|
||||
[hashtable]$Parameter
|
||||
)
|
||||
|
||||
# Only executed on primary Domain Controller
|
||||
If ((Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole -eq 5) {
|
||||
# Only executed on primary or standalone Domain Controller
|
||||
If (@('primary','standalone') -contains $Parameter['deployment.type']) {
|
||||
$GetContentSplat = @{
|
||||
Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', ".yml")
|
||||
Raw = $True
|
||||
|
Loading…
Reference in New Issue
Block a user