Delete commit history (containing proprietary code)
This commit is contained in:
commit
b59416f24f
2
README.md
Normal file
2
README.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Packer.Images [![Build Status](https://img.shields.io/drone/build/djpbessems/Packer.Images/Server2019?label=Server2019&server=https%3A%2F%2Fci.spamasaurus.com)](https://code.spamasaurus.com/djpbessems/Packer.Images/src/branch/Server2019) [![Build Status](https://img.shields.io/drone/build/djpbessems/Packer.Images/Windows10?label=Windows10&server=https%3A%2F%2Fci.spamasaurus.com)](https://code.spamasaurus.com/djpbessems/Packer.Images/src/branch/Windows10) [![Build Status](https://img.shields.io/drone/build/djpbessems/Packer.Images/ADCS?label=ADCS&server=https%3A%2F%2Fci.spamasaurus.com)](https://code.spamasaurus.com/djpbessems/Packer.Images/src/branch/ADCS) [![Build Status](https://img.shields.io/drone/build/djpbessems/Packer.Images/ADCS?label=ADDS&server=https%3A%2F%2Fci.spamasaurus.com)](https://code.spamasaurus.com/djpbessems/Packer.Images/src/branch/ADDS)
|
||||||
|
|
11
packer/variables.vsphere.json
Normal file
11
packer/variables.vsphere.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"vcenter_server": "bv11-vc01.bessems.lan",
|
||||||
|
"vsphere_username": "administrator@vsphere.local",
|
||||||
|
"vsphere_datacenter": "DeSchakel",
|
||||||
|
"vsphere_host": "bv11-esx.bessems.eu",
|
||||||
|
"vsphere_hostip": "192.168.11.200",
|
||||||
|
"vsphere_datastore": "Datastore02.SSD",
|
||||||
|
"vsphere_folder": "/Packer",
|
||||||
|
"vsphere_templatefolder": "/Templates",
|
||||||
|
"vsphere_network": "LAN"
|
||||||
|
}
|
52
scripts/Copy-DatastoreItem.ps1
Normal file
52
scripts/Copy-DatastoreItem.ps1
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
[CmdletBinding()]
|
||||||
|
Param(
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[string]$VMName,
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[string]$VSphereFQDN,
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[string]$VSphereUsername,
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[string]$VSpherePassword
|
||||||
|
)
|
||||||
|
|
||||||
|
$PowerCliConfigurationSplat = @{
|
||||||
|
Scope = 'User'
|
||||||
|
ParticipateInCEIP = $False
|
||||||
|
Confirm = $False
|
||||||
|
InvalidCertificateAction = 'Ignore'
|
||||||
|
}
|
||||||
|
Set-PowerCLIConfiguration @PowerCliConfigurationSplat
|
||||||
|
|
||||||
|
$ConnectVIServerSplat = @{
|
||||||
|
Server = $VSphereFQDN
|
||||||
|
User = "$VSphereUsername"
|
||||||
|
Password = "$VSpherePassword"
|
||||||
|
WarningAction = 'SilentlyContinue'
|
||||||
|
}
|
||||||
|
Connect-VIServer @ConnectVIServerSplat | Out-Null
|
||||||
|
|
||||||
|
$GetVMSplat = @{
|
||||||
|
Name = $VMName
|
||||||
|
}
|
||||||
|
$VM = Get-VM @GetVMSplat
|
||||||
|
|
||||||
|
$GetHarddiskSplat = @{
|
||||||
|
VM = $VM
|
||||||
|
}
|
||||||
|
$Harddisk = Get-Harddisk @GetHarddiskSplat
|
||||||
|
$VMFolder = ($Harddisk.Filename.Substring(0, $Harddisk.Filename.LastIndexOf('/')) -split ' ')[1]
|
||||||
|
|
||||||
|
$NewDatastoreDriveSplat = @{
|
||||||
|
Name = 'ds'
|
||||||
|
Datastore = ($VM | Get-Datastore)
|
||||||
|
}
|
||||||
|
New-DatastoreDrive @NewDatastoreDriveSplat
|
||||||
|
|
||||||
|
$CopyDatastoreItemSplat = @{
|
||||||
|
Item = "ds:\$($VMFolder)\*.vmdk"
|
||||||
|
Destination = (Get-Item $PWD)
|
||||||
|
}
|
||||||
|
Copy-DatastoreItem @CopyDatastoreItemSplat
|
||||||
|
|
||||||
|
Disconnect-VIServer * -Confirm:$False
|
8
scripts/Disable-WinRM.ps1
Normal file
8
scripts/Disable-WinRM.ps1
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" new enable=yes action=block
|
||||||
|
netsh advfirewall firewall set rule group="Windows Remote Management" new enable=yes
|
||||||
|
$winrmService = Get-Service -Name WinRM
|
||||||
|
if ($winrmService.Status -eq "Running"){
|
||||||
|
Disable-PSRemoting -Force
|
||||||
|
}
|
||||||
|
Stop-Service winrm
|
||||||
|
Set-Service -Name winrm -StartupType Disabled
|
18
scripts/Enable-WinRM.ps1
Normal file
18
scripts/Enable-WinRM.ps1
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
$NetworkListManager = [Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]"{DCB00C01-570F-4A9B-8D69-199FDBA5723B}"))
|
||||||
|
$Connections = $NetworkListManager.GetNetworkConnections()
|
||||||
|
$Connections | ForEach-Object { $_.GetNetwork().SetCategory(1) }
|
||||||
|
|
||||||
|
Enable-PSRemoting -Force
|
||||||
|
winrm quickconfig -q
|
||||||
|
winrm quickconfig -transport:http
|
||||||
|
winrm set winrm/config '@{MaxTimeoutms="1800000"}'
|
||||||
|
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="800"}'
|
||||||
|
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
|
||||||
|
winrm set winrm/config/service/auth '@{Basic="true"}'
|
||||||
|
winrm set winrm/config/client/auth '@{Basic="true"}'
|
||||||
|
winrm set winrm/config/listener?Address=*+Transport=HTTP '@{Port="5985"}'
|
||||||
|
netsh advfirewall firewall set rule group="Windows Remote Administration" new enable=yes
|
||||||
|
netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" new enable=yes action=allow
|
||||||
|
netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" profile=public new remoteip=any
|
||||||
|
Set-Service winrm -startuptype "auto"
|
||||||
|
Restart-Service winrm
|
2
scripts/Install-VMwareTools.cmd
Normal file
2
scripts/Install-VMwareTools.cmd
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
@rem Silent mode, basic UI, no reboot
|
||||||
|
e:\setup64 /s /v "/qb REBOOT=R"
|
73
scripts/MVMC/BlockList.xml
Normal file
73
scripts/MVMC/BlockList.xml
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<BlockList>
|
||||||
|
<!-- services to disable -->
|
||||||
|
<Services>
|
||||||
|
<Name>MVMCP2VAgent</Name>
|
||||||
|
<Name>VMTools</Name>
|
||||||
|
<Name> VMUpgradeHelper </Name>
|
||||||
|
<Name> vmvss </Name>
|
||||||
|
<Name>vmdesched</Name>
|
||||||
|
<Name>Virtual Server</Name>
|
||||||
|
<!-- Virtual Machine Helper -->
|
||||||
|
<Name>vmh</Name>
|
||||||
|
<!-- Xen-specific service -->
|
||||||
|
<Name>xensvc</Name>
|
||||||
|
</Services>
|
||||||
|
<!-- drivers to disable -->
|
||||||
|
<Drivers>
|
||||||
|
<Name>vmx_svga</Name>
|
||||||
|
<Name>vmmouse</Name>
|
||||||
|
<Name>vmscsi</Name>
|
||||||
|
<Name>amdpcn</Name>
|
||||||
|
<Name>PCnet</Name>
|
||||||
|
<Name>VMMEMCTL</Name>
|
||||||
|
|
||||||
|
<Name> pvscsi </Name>
|
||||||
|
<Name> vmci </Name>
|
||||||
|
<Name> vmmouse </Name>
|
||||||
|
<Name> vmaudio </Name>
|
||||||
|
<Name> vmrawdsk </Name>
|
||||||
|
<Name> vmxnet </Name>
|
||||||
|
<Name> vmxnet3ndis6 </Name>
|
||||||
|
<Name> vm3dmp </Name>
|
||||||
|
<Name> vmdebug </Name>
|
||||||
|
<Name> vmxnet3ndis5 </Name>
|
||||||
|
|
||||||
|
|
||||||
|
<Name>cirrus</Name>
|
||||||
|
<!-- storage drivers -->
|
||||||
|
<Name>buslogic</Name>
|
||||||
|
<Name>symc810</Name>
|
||||||
|
<Name>cpqarray</Name>
|
||||||
|
<Name>pcntn4m</Name>
|
||||||
|
<Name>cpqnf3</Name>
|
||||||
|
<Name>MRaidNT</Name>
|
||||||
|
<Name>Symc8XX</Name>
|
||||||
|
<!-- VIA chipset drivers -->
|
||||||
|
<Name>viaide</Name>
|
||||||
|
<Name>VIAudio</Name>
|
||||||
|
<Name>VIAPFD</Name>
|
||||||
|
<Name>viafilter</Name>
|
||||||
|
<Name>viaagp</Name>
|
||||||
|
<Name>viaagp1</Name>
|
||||||
|
<!-- network drivers: Intel(R) PRO/100 -->
|
||||||
|
<Name>E100B</Name>
|
||||||
|
<!-- tape drivers -->
|
||||||
|
<Name>4mmdat</Name>
|
||||||
|
<Name>4mmdat-SeSFT</Name>
|
||||||
|
<Name>SCSIChanger</Name>
|
||||||
|
|
||||||
|
<!-- Virtual Machine Monitor -->
|
||||||
|
<Name>vmm</Name>
|
||||||
|
<!-- Xen-specific drivers -->
|
||||||
|
<Name>xenevtchn</Name>
|
||||||
|
<Name>xenvbd</Name>
|
||||||
|
<Name>xennet</Name>
|
||||||
|
</Drivers>
|
||||||
|
<Programs>
|
||||||
|
<Name>ProMON</Name>
|
||||||
|
<Name>s3tray2</Name>
|
||||||
|
<Name>VMwareTray</Name>
|
||||||
|
<Name>VMwareUser</Name>
|
||||||
|
</Programs>
|
||||||
|
</BlockList>
|
BIN
scripts/MVMC/Microsoft.Accelerators.Framework.Core.dll
Normal file
BIN
scripts/MVMC/Microsoft.Accelerators.Framework.Core.dll
Normal file
Binary file not shown.
BIN
scripts/MVMC/Microsoft.Accelerators.Framework.dll
Normal file
BIN
scripts/MVMC/Microsoft.Accelerators.Framework.dll
Normal file
Binary file not shown.
BIN
scripts/MVMC/Microsoft.Accelerators.Mvmc.Engine.dll
Normal file
BIN
scripts/MVMC/Microsoft.Accelerators.Mvmc.Engine.dll
Normal file
Binary file not shown.
BIN
scripts/MVMC/Microsoft.Accelerators.Mvmc.ScxSshCommon.dll
Normal file
BIN
scripts/MVMC/Microsoft.Accelerators.Mvmc.ScxSshCommon.dll
Normal file
Binary file not shown.
BIN
scripts/MVMC/Microsoft.Accelerators.Mvmc.ScxSshWrapper_x64.dll
Normal file
BIN
scripts/MVMC/Microsoft.Accelerators.Mvmc.ScxSshWrapper_x64.dll
Normal file
Binary file not shown.
BIN
scripts/MVMC/Microsoft.Accelerators.Mvmc.ScxSshWrapper_x86.dll
Normal file
BIN
scripts/MVMC/Microsoft.Accelerators.Mvmc.ScxSshWrapper_x86.dll
Normal file
Binary file not shown.
BIN
scripts/MVMC/Microsoft.Practices.ServiceLocation.dll
Normal file
BIN
scripts/MVMC/Microsoft.Practices.ServiceLocation.dll
Normal file
Binary file not shown.
BIN
scripts/MVMC/Microsoft.Practices.Unity.dll
Normal file
BIN
scripts/MVMC/Microsoft.Practices.Unity.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
scripts/MVMC/Microsoft.WindowsAzure.Management.CloudService.dll
Normal file
BIN
scripts/MVMC/Microsoft.WindowsAzure.Management.CloudService.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
scripts/MVMC/Microsoft.WindowsAzure.Management.Service.dll
Normal file
BIN
scripts/MVMC/Microsoft.WindowsAzure.Management.Service.dll
Normal file
Binary file not shown.
BIN
scripts/MVMC/Microsoft.WindowsAzure.Management.ServiceBus.dll
Normal file
BIN
scripts/MVMC/Microsoft.WindowsAzure.Management.ServiceBus.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
scripts/MVMC/Microsoft.WindowsAzure.Management.SqlDatabase.dll
Normal file
BIN
scripts/MVMC/Microsoft.WindowsAzure.Management.SqlDatabase.dll
Normal file
Binary file not shown.
BIN
scripts/MVMC/Microsoft.WindowsAzure.Management.Sync.dll
Normal file
BIN
scripts/MVMC/Microsoft.WindowsAzure.Management.Sync.dll
Normal file
Binary file not shown.
BIN
scripts/MVMC/Microsoft.WindowsAzure.Management.Tools.Vhd.dll
Normal file
BIN
scripts/MVMC/Microsoft.WindowsAzure.Management.Tools.Vhd.dll
Normal file
Binary file not shown.
BIN
scripts/MVMC/Microsoft.WindowsAzure.Management.Websites.dll
Normal file
BIN
scripts/MVMC/Microsoft.WindowsAzure.Management.Websites.dll
Normal file
Binary file not shown.
BIN
scripts/MVMC/Microsoft.WindowsAzure.Management.dll
Normal file
BIN
scripts/MVMC/Microsoft.WindowsAzure.Management.dll
Normal file
Binary file not shown.
BIN
scripts/MVMC/Microsoft.WindowsAzure.Storage.dll
Normal file
BIN
scripts/MVMC/Microsoft.WindowsAzure.Storage.dll
Normal file
Binary file not shown.
BIN
scripts/MVMC/MvmcCmdlet.dll
Normal file
BIN
scripts/MVMC/MvmcCmdlet.dll
Normal file
Binary file not shown.
BIN
scripts/MVMC/MvmcCmdlet.psd1
Normal file
BIN
scripts/MVMC/MvmcCmdlet.psd1
Normal file
Binary file not shown.
BIN
scripts/MVMC/Sshlib_x64.dll
Normal file
BIN
scripts/MVMC/Sshlib_x64.dll
Normal file
Binary file not shown.
BIN
scripts/MVMC/Sshlib_x86.dll
Normal file
BIN
scripts/MVMC/Sshlib_x86.dll
Normal file
Binary file not shown.
BIN
scripts/MVMC/System.Reactive.Core.dll
Normal file
BIN
scripts/MVMC/System.Reactive.Core.dll
Normal file
Binary file not shown.
BIN
scripts/MVMC/System.Reactive.Interfaces.dll
Normal file
BIN
scripts/MVMC/System.Reactive.Interfaces.dll
Normal file
Binary file not shown.
BIN
scripts/MVMC/System.Reactive.Linq.dll
Normal file
BIN
scripts/MVMC/System.Reactive.Linq.dll
Normal file
Binary file not shown.
BIN
scripts/MVMC/System.Reactive.PlatformServices.dll
Normal file
BIN
scripts/MVMC/System.Reactive.PlatformServices.dll
Normal file
Binary file not shown.
BIN
scripts/MVMC/System.Reactive.Providers.dll
Normal file
BIN
scripts/MVMC/System.Reactive.Providers.dll
Normal file
Binary file not shown.
BIN
scripts/MVMC/System.Reactive.Windows.Threading.dll
Normal file
BIN
scripts/MVMC/System.Reactive.Windows.Threading.dll
Normal file
Binary file not shown.
51
scripts/New-WindowsImageJob.ps1
Normal file
51
scripts/New-WindowsImageJob.ps1
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#Requires -Modules 'dism'
|
||||||
|
Param(
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[string]$ImageName,
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[string]$SourceFolder,
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[string]$DestinationFile
|
||||||
|
)
|
||||||
|
|
||||||
|
$StartJobSplat = @{
|
||||||
|
ArgumentList = $ImageName, $SourceFolder, $DestinationFile
|
||||||
|
ScriptBlock = {
|
||||||
|
Param(
|
||||||
|
$ImageName,
|
||||||
|
$SourceFolder,
|
||||||
|
$DestinationFile
|
||||||
|
)
|
||||||
|
|
||||||
|
$NewWindowsImageSplat = @{
|
||||||
|
Name = $ImageName
|
||||||
|
CapturePath = $SourceFolder
|
||||||
|
ImagePath = $DestinationFile
|
||||||
|
Verify = $True
|
||||||
|
}
|
||||||
|
New-WindowsImage @NewWindowsImageSplat
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$Job = Start-Job @StartJobSplat
|
||||||
|
|
||||||
|
While ($Job.State -eq 'Running') {
|
||||||
|
$GetItemSplat = @{
|
||||||
|
Path = $DestinationFile
|
||||||
|
ErrorAction = 'SilentlyContinue'
|
||||||
|
}
|
||||||
|
$OutputFile = Get-Item @GetItemSplat
|
||||||
|
If ($OutputFile) {
|
||||||
|
Write-Host "Export in progress ... $($OutputFile.FullName); Size: $('{0:n2}' -f ($OutputFile.Length / 1MB))MB"
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
Write-Host "Export initiating ... "
|
||||||
|
}
|
||||||
|
|
||||||
|
$StartSleepSplat = @{
|
||||||
|
Seconds = 30
|
||||||
|
}
|
||||||
|
Start-Sleep @StartSleepSplat
|
||||||
|
}
|
||||||
|
|
||||||
|
Receive-Job $Job
|
||||||
|
Remove-Job $Job
|
39
scripts/Remove-Resources.ps1
Normal file
39
scripts/Remove-Resources.ps1
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
[CmdletBinding()]
|
||||||
|
Param(
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[string]$VMName,
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[string]$VSphereFQDN,
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[string]$VSphereUsername,
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[string]$VSpherePassword
|
||||||
|
)
|
||||||
|
|
||||||
|
$PowerCliConfigurationSplat = @{
|
||||||
|
Scope = 'User'
|
||||||
|
ParticipateInCEIP = $False
|
||||||
|
Confirm = $False
|
||||||
|
InvalidCertificateAction = 'Ignore'
|
||||||
|
}
|
||||||
|
Set-PowerCLIConfiguration @PowerCliConfigurationSplat
|
||||||
|
|
||||||
|
$ConnectVIServerSplat = @{
|
||||||
|
Server = $VSphereFQDN
|
||||||
|
User = "$VSphereUsername"
|
||||||
|
Password = "$VSpherePassword"
|
||||||
|
WarningAction = 'SilentlyContinue'
|
||||||
|
}
|
||||||
|
Connect-VIServer @ConnectVIServerSplat | Out-Null
|
||||||
|
|
||||||
|
$RemoveVMSplat = @{
|
||||||
|
VM = "$($VMName)*"
|
||||||
|
DeletePermanently = $True
|
||||||
|
Confirm = $False
|
||||||
|
ErrorAction = 'SilentlyContinue'
|
||||||
|
}
|
||||||
|
Remove-VM @RemoveVMSplat
|
||||||
|
|
||||||
|
# Also delete ISO/floppy?
|
||||||
|
|
||||||
|
Disconnect-VIServer * -Confirm:$False
|
23
scripts/Set-NetworkProfile.ps1
Normal file
23
scripts/Set-NetworkProfile.ps1
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# You cannot enable Windows PowerShell Remoting on network connections that are set to Public
|
||||||
|
# Spin through all the network locations and if they are set to Public, set them to Private
|
||||||
|
# using the INetwork interface:
|
||||||
|
# http://msdn.microsoft.com/en-us/library/windows/desktop/aa370750(v=vs.85).aspx
|
||||||
|
# For more info, see:
|
||||||
|
# http://blogs.msdn.com/b/powershell/archive/2009/04/03/setting-network-location-to-private.aspx
|
||||||
|
|
||||||
|
# Network location feature was only introduced in Windows Vista - no need to bother with this
|
||||||
|
# if the operating system is older than Vista
|
||||||
|
if([environment]::OSVersion.version.Major -lt 6) { return }
|
||||||
|
|
||||||
|
# You cannot change the network location if you are joined to a domain, so abort
|
||||||
|
if(1,3,4,5 -contains (Get-WmiObject win32_computersystem).DomainRole) { return }
|
||||||
|
|
||||||
|
# Get network connections
|
||||||
|
$networkListManager = [Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]"{DCB00C01-570F-4A9B-8D69-199FDBA5723B}"))
|
||||||
|
$connections = $networkListManager.GetNetworkConnections()
|
||||||
|
|
||||||
|
$connections |foreach {
|
||||||
|
Write-Host $_.GetNetwork().GetName()"category was previously set to"$_.GetNetwork().GetCategory()
|
||||||
|
$_.GetNetwork().SetCategory(1)
|
||||||
|
Write-Host $_.GetNetwork().GetName()"changed to category"$_.GetNetwork().GetCategory()
|
||||||
|
}
|
7
scripts/Uninstall-VMwareTools.Sysprep.cmd
Normal file
7
scripts/Uninstall-VMwareTools.Sysprep.cmd
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
@rem Uninstall VMware Tools
|
||||||
|
@rem (wait for orphaned child process to finish)
|
||||||
|
@rem Silent mode, basic UI, no reboot
|
||||||
|
start "Uninstall VMware Tools" /b /w e:\setup64 /s /v "/qb REBOOT=R REMOVE=ALL"
|
||||||
|
|
||||||
|
@rem Initiate Sysprep
|
||||||
|
C:\Windows\System32\Sysprep\sysprep.exe /generalize /oobe /unattend:A:\Sysprep_Unattend.xml /quiet /shutdown
|
55
scripts/Update-Manifest.ps1
Normal file
55
scripts/Update-Manifest.ps1
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#Requires -Modules 'powershell-yaml'
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param(
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[ValidateScript({
|
||||||
|
If (Test-Path($_)) {
|
||||||
|
$True
|
||||||
|
} Else {
|
||||||
|
Throw "'$_' is not a valid filename (within working directory '$PWD'), or access denied; aborting."
|
||||||
|
}
|
||||||
|
})]
|
||||||
|
[string]$ManifestFileName
|
||||||
|
)
|
||||||
|
|
||||||
|
$GetItemSplat = @{
|
||||||
|
Path = $ManifestFileName
|
||||||
|
}
|
||||||
|
$ManifestFile = Get-Item @GetItemSplat
|
||||||
|
|
||||||
|
$SetLocationSplat = @{
|
||||||
|
Path = $ManifestFile.DirectoryName
|
||||||
|
}
|
||||||
|
Set-Location @SetLocationSplat
|
||||||
|
|
||||||
|
$GetContentSplat = @{
|
||||||
|
Path = $ManifestFile.FullName
|
||||||
|
}
|
||||||
|
$Manifest = Get-Content @GetContentSplat
|
||||||
|
|
||||||
|
$UpdatedManifest = ForEach ($Line in $Manifest) {
|
||||||
|
Write-Host "Processing '$($Line)' ..."
|
||||||
|
If ($Line -match '^SHA256\((.+)\)= ([0-9a-fA-F]{64})$') {
|
||||||
|
If (Test-Path $Matches[1]) {
|
||||||
|
$GetFileHashSplat = @{
|
||||||
|
Path = $Matches[1]
|
||||||
|
Algorithm = 'SHA256'
|
||||||
|
}
|
||||||
|
Write-Host "Updating checksum..."
|
||||||
|
"SHA256($($Matches[1]))= $((Get-FileHash @GetFileHashSplat).Hash)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($UpdatedManifest -ne $Null) {
|
||||||
|
$SetContentSplat = @{
|
||||||
|
Path = $ManifestFile.FullName
|
||||||
|
Value = $UpdatedManifest
|
||||||
|
Force = $True
|
||||||
|
Confirm = $False
|
||||||
|
}
|
||||||
|
Set-Content @SetContentSplat
|
||||||
|
} Else {
|
||||||
|
Write-Host "Failed updating manifest."
|
||||||
|
Exit 1
|
||||||
|
}
|
228
scripts/Update-OvfConfiguration.ps1
Normal file
228
scripts/Update-OvfConfiguration.ps1
Normal file
@ -0,0 +1,228 @@
|
|||||||
|
#Requires -Modules 'powershell-yaml'
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param(
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[ValidateScript({
|
||||||
|
If ([boolean]($_.IndexOfAny([io.path]::GetInvalidFileNameChars()) -lt 0)) {
|
||||||
|
$True
|
||||||
|
} Else {
|
||||||
|
Throw 'Provided input contains invalid characters; aborting.'
|
||||||
|
}
|
||||||
|
})]
|
||||||
|
[string]$TemplateName,
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[ValidateScript({
|
||||||
|
If (Test-Path($_)) {
|
||||||
|
$True
|
||||||
|
} Else {
|
||||||
|
Throw "'$_' is not a valid filename (within working directory '$PWD'), or access denied; aborting."
|
||||||
|
}
|
||||||
|
})]
|
||||||
|
[string]$OVFFile
|
||||||
|
)
|
||||||
|
|
||||||
|
$GetContentSplat = @{
|
||||||
|
Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', ".$($TemplateName).yml")
|
||||||
|
Raw = $True
|
||||||
|
}
|
||||||
|
$RawContent = Get-Content @GetContentSplat
|
||||||
|
$ConvertFromYamlSplat = @{
|
||||||
|
Yaml = $RawContent
|
||||||
|
AllDocuments = $True
|
||||||
|
}
|
||||||
|
$OVFConfig = ConvertFrom-Yaml @ConvertFromYamlSplat
|
||||||
|
|
||||||
|
$SourceFile = Get-Item -Path $OVFFile
|
||||||
|
$GetContentSplat = @{
|
||||||
|
Path = $SourceFile.FullName
|
||||||
|
}
|
||||||
|
$XML = [xml](Get-Content @GetContentSplat)
|
||||||
|
$NS = [System.Xml.XmlNamespaceManager]$XML.NameTable
|
||||||
|
[void]$NS.AddNamespace('Any', $XML.DocumentElement.xmlns)
|
||||||
|
|
||||||
|
If ($OVFConfig.DeploymentConfigurations.Count -gt 0) {
|
||||||
|
$XMLSection = $XML.CreateElement('DeploymentOptionSection', $XML.DocumentElement.xmlns)
|
||||||
|
$XMLSectionInfo = $XML.CreateElement('Info', $XML.DocumentElement.xmlns)
|
||||||
|
$XMLSectionInfo.InnerText = 'Deployment Type'
|
||||||
|
[void]$XMLSection.AppendChild($XMLSectionInfo)
|
||||||
|
|
||||||
|
ForEach ($Configuration in $OVFConfig.DeploymentConfigurations) {
|
||||||
|
$XMLConfig = $XML.CreateElement('Configuration', $XML.DocumentElement.xmlns)
|
||||||
|
|
||||||
|
$XMLConfigAttrId = $XML.CreateAttribute('id', $XML.DocumentElement.ovf)
|
||||||
|
$XMLConfigAttrId.Value = $Configuration.Id
|
||||||
|
|
||||||
|
$XMLConfigLabel = $XML.CreateElement('Label', $XML.DocumentElement.xmlns)
|
||||||
|
$XMLConfigLabel.InnerText = $Configuration.Label
|
||||||
|
|
||||||
|
$XMLConfigDescription = $XML.CreateElement('Description', $XML.DocumentElement.xmlns)
|
||||||
|
$XMLConfigDescription.InnerText = $Configuration.Description
|
||||||
|
|
||||||
|
[void]$XMLConfig.Attributes.Append($XMLConfigAttrId)
|
||||||
|
[void]$XMLConfig.AppendChild($XMLConfigLabel)
|
||||||
|
[void]$XMLConfig.AppendChild($XMLConfigDescription)
|
||||||
|
|
||||||
|
[void]$XMLSection.AppendChild($XMLConfig)
|
||||||
|
}
|
||||||
|
[void]$XML.SelectSingleNode('//Any:Envelope', $NS).InsertAfter($XMLSection, $XML.SelectSingleNode('//Any:NetworkSection', $NS))
|
||||||
|
Write-Host "Inserted 'DeploymentOptionSection' with $($Configuration.Count) nodes"
|
||||||
|
}
|
||||||
|
|
||||||
|
$XMLAttrTransport = $XML.CreateAttribute('transport', $XML.DocumentElement.ovf)
|
||||||
|
$XMLAttrTransport.Value = 'com.vmware.guestInfo'
|
||||||
|
[void]$XML.SelectSingleNode('//Any:VirtualHardwareSection', $NS).Attributes.Append($XMLAttrTransport)
|
||||||
|
|
||||||
|
$XMLProductSection = $XML.SelectSingleNode('//Any:ProductSection', $NS)
|
||||||
|
If ($XMLProductSection -eq $Null) {
|
||||||
|
$XMLProductSection = $XML.CreateElement('ProductSection', $XML.DocumentElement.xmlns)
|
||||||
|
[void]$XML.SelectSingleNode('//Any:VirtualSystem', $NS).AppendChild($XMLProductSection)
|
||||||
|
Write-Host "Inserted 'ProductSection'"
|
||||||
|
} Else {
|
||||||
|
ForEach ($Child in $XMLProductSection.SelectNodes('//Any:ProductSection/child::*', $NS)) {
|
||||||
|
[void]$Child.ParentNode.RemoveChild($Child)
|
||||||
|
}
|
||||||
|
Write-Host "Destroyed pre-existing children in 'ProductSection'"
|
||||||
|
}
|
||||||
|
$XMLProductSectionInfo = $XML.CreateElement('Info', $XML.DocumentElement.xmlns)
|
||||||
|
$XMLProductSectionInfo.InnerText = 'Information about the installed software'
|
||||||
|
[void]$XMLProductSection.AppendChild($XMLProductSectionInfo)
|
||||||
|
Write-Host "Inserted new 'Info' into 'ProductSection'"
|
||||||
|
|
||||||
|
ForEach ($Category in $OVFConfig.PropertyCategories) {
|
||||||
|
If ($Category.Name -ne '') {
|
||||||
|
$XMLCategory = $XML.CreateElement('Category', $XML.DocumentElement.xmlns)
|
||||||
|
$XMLCategory.InnerText = $Category.Name
|
||||||
|
[void]$XMLProductSection.AppendChild($XMLCategory)
|
||||||
|
Write-Host "Inserted new 'Category' into 'ProductSection'"
|
||||||
|
}
|
||||||
|
|
||||||
|
ForEach ($Property in $Category.ProductProperties) {
|
||||||
|
$XMLProperty = $XML.CreateElement('Property', $XML.DocumentElement.xmlns)
|
||||||
|
|
||||||
|
$XMLPropertyAttrKey = $XML.CreateAttribute('key', $XML.DocumentElement.ovf)
|
||||||
|
$XMLPropertyAttrKey.Value = $Property.Key
|
||||||
|
$XMLPropertyAttrType = $XML.CreateAttribute('type', $XML.DocumentElement.ovf)
|
||||||
|
Switch -regex ($Property.Type) {
|
||||||
|
'boolean' {
|
||||||
|
$XMLPropertyAttrType.Value = 'boolean'
|
||||||
|
}
|
||||||
|
'int' {
|
||||||
|
$XMLPropertyAttrType.Value = 'uint8'
|
||||||
|
$Qualifiers = @()
|
||||||
|
If ($Property.Type -match 'int\((\d*)\.\.(\d*)\)') {
|
||||||
|
If ($Matches[1]) {
|
||||||
|
$Qualifiers += "MinValue($($Matches[1]))"
|
||||||
|
}
|
||||||
|
If ($Matches[2]) {
|
||||||
|
$Qualifiers += "MaxValue($($Matches[2]))"
|
||||||
|
}
|
||||||
|
$XMLPropertyAttrQualifiers = $XML.CreateAttribute('qualifiers', $XML.DocumentElement.ovf)
|
||||||
|
$XMLPropertyAttrQualifiers.Value = $Qualifiers -join ' '
|
||||||
|
[void]$XMLProperty.Attributes.Append($XMLPropertyAttrQualifiers)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'ip' {
|
||||||
|
$XMLPropertyAttrType.Value = 'string'
|
||||||
|
$XMLPropertyAttrQualifiers = $XML.CreateAttribute('qualifiers', $XML.DocumentElement.vmw)
|
||||||
|
$XMLPropertyAttrQualifiers.Value = 'Ip'
|
||||||
|
[void]$XMLProperty.Attributes.Append($XMLPropertyAttrQualifiers)
|
||||||
|
}
|
||||||
|
'password' {
|
||||||
|
$XMLPropertyAttrType.Value = 'string'
|
||||||
|
$XMLPropertyAttrPassword = $XML.CreateAttribute('password', $XML.DocumentElement.ovf)
|
||||||
|
$XMLPropertyAttrPassword.Value = 'true'
|
||||||
|
[void]$XMLProperty.Attributes.Append($XMLPropertyAttrPassword)
|
||||||
|
|
||||||
|
$Qualifiers = @()
|
||||||
|
If ($Property.Type -match 'password\((\d*)\.\.(\d*)\)') {
|
||||||
|
If ($Matches[1]) {
|
||||||
|
$Qualifiers += "MinLen($($Matches[1]))"
|
||||||
|
}
|
||||||
|
If ($Matches[2]) {
|
||||||
|
$Qualifiers += "MaxLen($($Matches[2]))"
|
||||||
|
}
|
||||||
|
$XMLPropertyAttrQualifiers = $XML.CreateAttribute('qualifiers', $XML.DocumentElement.ovf)
|
||||||
|
$XMLPropertyAttrQualifiers.Value = $Qualifiers -join ' '
|
||||||
|
[void]$XMLProperty.Attributes.Append($XMLPropertyAttrQualifiers)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'string' {
|
||||||
|
$XMLPropertyAttrType.Value = 'string'
|
||||||
|
$Qualifiers = @()
|
||||||
|
If ($Property.Type -match 'string\((\d*)\.\.(\d*)\)') {
|
||||||
|
If ($Matches[1]) {
|
||||||
|
$Qualifiers += "MinLen($($Matches[1]))"
|
||||||
|
}
|
||||||
|
If ($Matches[2]) {
|
||||||
|
$Qualifiers += "MaxLen($($Matches[2]))"
|
||||||
|
}
|
||||||
|
$XMLPropertyAttrQualifiers = $XML.CreateAttribute('qualifiers', $XML.DocumentElement.ovf)
|
||||||
|
$XMLPropertyAttrQualifiers.Value = $Qualifiers -join ' '
|
||||||
|
[void]$XMLProperty.Attributes.Append($XMLPropertyAttrQualifiers)
|
||||||
|
} ElseIf ($Property.Type -match 'string\[(.*)\]') {
|
||||||
|
$XMLPropertyAttrQualifiers = $XML.CreateAttribute('qualifiers', $XML.DocumentElement.ovf)
|
||||||
|
$XMLPropertyAttrQualifiers.Value = "ValueMap{$($Matches[1] -replace '","', '", "')}"
|
||||||
|
[void]$XMLProperty.Attributes.Append($XMLPropertyAttrQualifiers)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$XMLPropertyAttrUserConfigurable = $XML.CreateAttribute('userConfigurable', $XML.DocumentElement.ovf)
|
||||||
|
$XMLPropertyAttrUserConfigurable.Value = "$([boolean]$Property.UserConfigurable)".ToLower()
|
||||||
|
$XMLPropertyAttrValue = $XML.CreateAttribute('value', $XML.DocumentElement.ovf)
|
||||||
|
If ($Property.Type -eq 'boolean') {
|
||||||
|
$XMLPropertyAttrValue.Value = "$([boolean]$Property.DefaultValue)".ToLower()
|
||||||
|
} Else {
|
||||||
|
$XMLPropertyAttrValue.Value = $Property.DefaultValue
|
||||||
|
}
|
||||||
|
[void]$XMLProperty.Attributes.Append($XMLPropertyAttrKey)
|
||||||
|
[void]$XMLProperty.Attributes.Append($XMLPropertyAttrType)
|
||||||
|
[void]$XMLProperty.Attributes.Append($XMLPropertyAttrUserConfigurable)
|
||||||
|
[void]$XMLProperty.Attributes.Append($XMLPropertyAttrValue)
|
||||||
|
|
||||||
|
If ($Property.Label) {
|
||||||
|
$XMLPropertyLabel = $XML.CreateElement('Label', $XML.DocumentElement.xmlns)
|
||||||
|
$XMLPropertyLabel.InnerText = $Property.Label
|
||||||
|
[void]$XMLProperty.AppendChild($XMLPropertyLabel)
|
||||||
|
}
|
||||||
|
If ($Property.Description) {
|
||||||
|
$XMLPropertyDescription = $XML.CreateElement('Description', $XML.DocumentElement.xmlns)
|
||||||
|
$XMLPropertyDescription.InnerText = $Property.Description
|
||||||
|
[void]$XMLProperty.AppendChild($XMLPropertyDescription)
|
||||||
|
}
|
||||||
|
|
||||||
|
If (($Property.Configurations.Count -eq 1) -and ($Property.Configurations -eq '*')) {
|
||||||
|
$XMLPropertyAttrConfiguration = $XML.CreateAttribute('configuration', $XML.DocumentElement.ovf)
|
||||||
|
$XMLPropertyAttrConfiguration.Value = $OVFConfig.DeploymentConfigurations.Id -join ' '
|
||||||
|
[void]$XMLProperty.Attributes.Append($XMLPropertyAttrConfiguration)
|
||||||
|
} ElseIf ($Property.Configurations.Count -gt 0) {
|
||||||
|
$XMLPropertyAttrConfiguration = $XML.CreateAttribute('configuration', $XML.DocumentElement.ovf)
|
||||||
|
$XMLPropertyAttrConfiguration.Value = $Property.Configurations -join ' '
|
||||||
|
[void]$XMLProperty.Attributes.Append($XMLPropertyAttrConfiguration)
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($Property.Value.Count -eq 1) {
|
||||||
|
$XMLPropertyAttrValue = $XML.CreateAttribute('value', $XML.DocumentElement.ovf)
|
||||||
|
$XMLPropertyAttrValue.Value = $Property.Value
|
||||||
|
[void]$XMLProperty.Attributes.Append($XMLPropertyAttrValue)
|
||||||
|
} ElseIf ($Property.Value.Count -gt 1) {
|
||||||
|
ForEach ($Value in $Property.Value) {
|
||||||
|
$XMLValue = $XML.CreateElement('Value', $XML.DocumentElement.xmlns)
|
||||||
|
|
||||||
|
$XMLValueAttrValue = $XML.CreateAttribute('value', $XML.DocumentElement.ovf)
|
||||||
|
$XMLValueAttrValue.Value = $Value
|
||||||
|
$XMLValueAttrConfiguration = $XML.CreateAttribute('configuration', $XML.DocumentElement.ovf)
|
||||||
|
$XMLValueAttrConfiguration.Value = $Value
|
||||||
|
|
||||||
|
[void]$XMLValue.Attributes.Append($XMLValueAttrValue)
|
||||||
|
[void]$XMLValue.Attributes.Append($XMLValueAttrConfiguration)
|
||||||
|
|
||||||
|
[void]$XMLProperty.AppendChild($XMLValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[void]$XMLProductSection.AppendChild($XMLProperty)
|
||||||
|
}
|
||||||
|
Write-Host "Inserted $($Category.ProductProperties.Count) new node(s) into 'ProductSection'"
|
||||||
|
}
|
||||||
|
|
||||||
|
$XML.Save($SourceFile.FullName)
|
Loading…
Reference in New Issue
Block a user