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
|
# Check for mandatory values
|
||||||
If (!($ovfPropertyValues['guestinfo.hostname'] -and
|
Switch ($ovfPropertyValues['deployment.type']) {
|
||||||
$ovfPropertyValues['guestinfo.ipaddress'] -and
|
'primary' {
|
||||||
$ovfPropertyValues['guestinfo.dnsserver'] -and
|
$MandatoryProperties, $MissingProperties = @('guestinfo.hostname', 'guestinfo.ipaddress', 'guestinfo.prefixlength', 'guestinfo.gateway', 'addsconfig.domainname', 'addsconfig.netbiosname', 'addsconfig.administratorpw', 'addsconfig.safemodepw', 'addsconfig.ntpserver'), @()
|
||||||
$ovfPropertyValues['guestinfo.prefixlength'] -and
|
}
|
||||||
$ovfPropertyValues['guestinfo.gateway'] -and
|
'secondary' {
|
||||||
$ovfPropertyValues['addsconfig.domainname'] -and
|
$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'), @()
|
||||||
$ovfPropertyValues['addsconfig.netbiosname'] -and
|
}
|
||||||
$ovfPropertyValues['addsconfig.administratorpw'] -and
|
'standalone' {
|
||||||
$ovfPropertyValues['addsconfig.safemodepw'])) {
|
$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.
|
# Mandatory values missing, cannot provision.
|
||||||
$WriteEventLogSplat = @{
|
$WriteEventLogSplat = @{
|
||||||
LogName = 'Application'
|
LogName = 'Application'
|
||||||
Source = 'OVF-Properties'
|
Source = 'OVF-Properties'
|
||||||
EntryType = 'Error'
|
EntryType = 'Error'
|
||||||
EventID = 66
|
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
|
Write-EventLog @WriteEventLogSplat
|
||||||
& schtasks.exe /Change /TN 'OVF-Properties' /DISABLE
|
& schtasks.exe /Change /TN 'OVF-Properties' /DISABLE
|
||||||
|
@ -4,8 +4,8 @@ Param(
|
|||||||
[hashtable]$Parameter
|
[hashtable]$Parameter
|
||||||
)
|
)
|
||||||
|
|
||||||
# Only executed on primary Domain Controller
|
# Only executed on primary or standalone Domain Controller
|
||||||
If ((Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole -eq 5) {
|
If (@('primary','standalone') -contains $Parameter['deployment.type']) {
|
||||||
$GetContentSplat = @{
|
$GetContentSplat = @{
|
||||||
Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', ".csv")
|
Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', ".csv")
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@ Param(
|
|||||||
[hashtable]$Parameter
|
[hashtable]$Parameter
|
||||||
)
|
)
|
||||||
|
|
||||||
# Only executed on primary Domain Controller
|
# Only executed on primary or standalone Domain Controller
|
||||||
If ((Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole -eq 5) {
|
If (@('primary','standalone') -contains $Parameter['deployment.type']) {
|
||||||
$GetContentSplat = @{
|
$GetContentSplat = @{
|
||||||
Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', ".csv")
|
Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', ".csv")
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@ Param(
|
|||||||
[hashtable]$Parameter
|
[hashtable]$Parameter
|
||||||
)
|
)
|
||||||
|
|
||||||
# Only executed on primary Domain Controller
|
# Only executed on primary or standalone Domain Controller
|
||||||
If ((Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole -eq 5) {
|
If (@('primary','standalone') -contains $Parameter['deployment.type']) {
|
||||||
$GetContentSplat = @{
|
$GetContentSplat = @{
|
||||||
Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', ".csv")
|
Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', ".csv")
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@ Param(
|
|||||||
[hashtable]$Parameter
|
[hashtable]$Parameter
|
||||||
)
|
)
|
||||||
|
|
||||||
# Only executed on primary Domain Controller
|
# Only executed on primary or standalone Domain Controller
|
||||||
If ((Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole -eq 5) {
|
If (@('primary','standalone') -contains $Parameter['deployment.type']) {
|
||||||
$PSDrive = Get-PSDrive -Name 'AD'
|
$PSDrive = Get-PSDrive -Name 'AD'
|
||||||
If ([boolean]$PSDrive -eq $False) {
|
If ([boolean]$PSDrive -eq $False) {
|
||||||
$NewPSDriveSplat = @{
|
$NewPSDriveSplat = @{
|
||||||
|
@ -4,8 +4,8 @@ Param(
|
|||||||
[hashtable]$Parameter
|
[hashtable]$Parameter
|
||||||
)
|
)
|
||||||
|
|
||||||
# Only executed on primary Domain Controller
|
# Only executed on primary or standalone Domain Controller
|
||||||
If ((Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole -eq 5) {
|
If (@('primary','standalone') -contains $Parameter['deployment.type']) {
|
||||||
$GetContentSplat = @{
|
$GetContentSplat = @{
|
||||||
Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', '.yml')
|
Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', '.yml')
|
||||||
Raw = $true
|
Raw = $true
|
||||||
|
@ -4,8 +4,8 @@ Param(
|
|||||||
[hashtable]$Parameter
|
[hashtable]$Parameter
|
||||||
)
|
)
|
||||||
|
|
||||||
# Only executed on secondary Domain Controller
|
# Only executed on secondary or standalone Domain Controller
|
||||||
If ((Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole -eq 4) {
|
If (@('secondary','standalone') -contains $Parameter['deployment.type']) {
|
||||||
$AddDhcpServerv4ScopeSplat = @{
|
$AddDhcpServerv4ScopeSplat = @{
|
||||||
Name = 'Default DHCP scope'
|
Name = 'Default DHCP scope'
|
||||||
StartRange = [ipaddress]$Parameter['dhcpconfig.startip']
|
StartRange = [ipaddress]$Parameter['dhcpconfig.startip']
|
||||||
|
@ -5,7 +5,7 @@ Param(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Only executed on secondary Domain Controller
|
# 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
|
# Wait for secondary DHCP server to be registered in DNS
|
||||||
$Timestamp, $TimeoutMinutes = (Get-Date), 5
|
$Timestamp, $TimeoutMinutes = (Get-Date), 5
|
||||||
Do {
|
Do {
|
||||||
|
@ -4,8 +4,8 @@ Param(
|
|||||||
[hashtable]$Parameter
|
[hashtable]$Parameter
|
||||||
)
|
)
|
||||||
|
|
||||||
# Only executed on secondary Domain Controller
|
# Only executed on secondary or standalone Domain Controller
|
||||||
If ((Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole -eq 4) {
|
If (@('secondary','standalone') -contains $Parameter['deployment.type']) {
|
||||||
$GetContentSplat = @{
|
$GetContentSplat = @{
|
||||||
Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', '.yml')
|
Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', '.yml')
|
||||||
Raw = $True
|
Raw = $True
|
||||||
|
@ -4,8 +4,8 @@ Param(
|
|||||||
[hashtable]$Parameter
|
[hashtable]$Parameter
|
||||||
)
|
)
|
||||||
|
|
||||||
# Only executed on primary Domain Controller
|
# Only executed on primary or standalone Domain Controller
|
||||||
If ((Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole -eq 5) {
|
If (@('primary','standalone') -contains $Parameter['deployment.type']) {
|
||||||
$GetContentSplat = @{
|
$GetContentSplat = @{
|
||||||
Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', '.yml')
|
Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', '.yml')
|
||||||
Raw = $True
|
Raw = $True
|
||||||
|
@ -4,8 +4,8 @@ Param(
|
|||||||
[hashtable]$Parameter
|
[hashtable]$Parameter
|
||||||
)
|
)
|
||||||
|
|
||||||
# Only executed on primary Domain Controller
|
# Only executed on primary or standalone Domain Controller
|
||||||
If ((Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole -eq 5) {
|
If (@('primary','standalone') -contains $Parameter['deployment.type']) {
|
||||||
$NewPSSessionSplat = @{
|
$NewPSSessionSplat = @{
|
||||||
ComputerName = $Parameter['guestinfo.hostname']
|
ComputerName = $Parameter['guestinfo.hostname']
|
||||||
Credential = New-Object System.Management.Automation.PSCredential(
|
Credential = New-Object System.Management.Automation.PSCredential(
|
||||||
|
@ -4,8 +4,8 @@ Param(
|
|||||||
[hashtable]$Parameter
|
[hashtable]$Parameter
|
||||||
)
|
)
|
||||||
|
|
||||||
# Only executed on primary Domain Controller
|
# Only executed on primary or standalone Domain Controller
|
||||||
If ((Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole -eq 5) {
|
If (@('primary','standalone') -contains $Parameter['deployment.type']) {
|
||||||
$PSDrive = Get-PSDrive -Name 'AD'
|
$PSDrive = Get-PSDrive -Name 'AD'
|
||||||
If ([boolean]$PSDrive -eq $False) {
|
If ([boolean]$PSDrive -eq $False) {
|
||||||
$NewPSDriveSplat = @{
|
$NewPSDriveSplat = @{
|
||||||
|
@ -4,8 +4,8 @@ Param(
|
|||||||
[hashtable]$Parameter
|
[hashtable]$Parameter
|
||||||
)
|
)
|
||||||
|
|
||||||
# Only executed on primary Domain Controller
|
# Only executed on primary or standalone Domain Controller
|
||||||
If ((Get-WmiObject -Class 'Win32_ComputerSystem').DomainRole -eq 5) {
|
If (@('primary','standalone') -contains $Parameter['deployment.type']) {
|
||||||
$GetContentSplat = @{
|
$GetContentSplat = @{
|
||||||
Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', ".yml")
|
Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', ".yml")
|
||||||
Raw = $True
|
Raw = $True
|
||||||
|
Loading…
Reference in New Issue
Block a user