windows-trial-lab updates/improvements

jowjDev
Micah R Ledbetter 8 years ago
parent 7989f67797
commit 2652ba63ae

@ -24,7 +24,7 @@ PREREQUISITES:
[parameter(mandatory=$true,ParameterSetName="VagrantUp")] [switch] $VagrantUp,
[parameter(mandatory=$true,ParameterSetName="ShowConfig")] [switch] $ShowConfig,
#[string] $baseOutDir = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..\iso\wintriallabl"),
#[string] $baseOutDir = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..\iso\wintriallab"),
[string] $baseOutDir = "E:\Micah\iso\wintriallab",
[string] $tempDirOverride,
[string] $tag,
@ -68,9 +68,6 @@ function Build-PackerFile {
[cmdletbinding()]
param(
[parameter(mandatory=$true)] $packerFile,
[parameter(mandatory=$true)] $vagrantTemplate,
[parameter(mandatory=$true)] [string] $vagrantBoxName,
$tag,
$packerCacheDir,
$outDir,
[switch] $force,
@ -82,11 +79,24 @@ function Build-PackerFile {
if ($packerCacheDir) { $env:PACKER_CACHE_DIR = $packerCacheDir }
if (test-path $outDir) {
if ($force) { rm -force -recurse $outDir }
else { throw "Outdir already exists at '$outDir'" }
if ($force) {
rm -force -recurse $outDir
}
else {
throw "Outdir already exists at '$outDir'"
}
}
pushd (get-item $packerFile | select -expand fullname | split-path -parent)
$packerDir = get-item $packerFile | select -expand fullname | split-path -parent
if (Test-Path "$packerDir\output-*") {
if ($force) {
rm -recurse -force "$packerDir\output-*"
}
else {
throw "Existing packer tmp dir(s) at '$packerDir\output-*'"
}
}
pushd $packerDir
try {
write-host "Building packer file '$($packerFile.fullname)' to directory '$outDir'..."
$packerCall = ''
@ -108,7 +118,6 @@ function Build-PackerFile {
if ($outBox.fullname -notmatch [Regex]::Escape($packedBoxPath)) {
throw "Found an output box '$outBox', but it doesn't match the expected packed box path of '$packedBoxPath'"
}
cp "$vagrantTemplate" "$outDir\Vagrantfile"
write-verbose "Packed .box file: '$packedBoxPath'"
}
@ -205,17 +214,7 @@ if ($baseConfigName) {
}
if ($BuildPacker) {
$bpfParam = @{
packerFile = $packerFile
vagrantTemplate = $vagrantTemplate
vagrantBoxName = $fullConfigName
tag = $tag
packerCacheDir = $packerCacheDir
outDir = $packerOutDir
force = $force
whatIf = $whatIf
}
Build-PackerFile @bpfParam
Build-PackerFile -packerFile $packerFile -packerCacheDir $packerCacheDir -outDir $packerOutDir -force:$force -whatif:$whatif
}
if ($AddToVagrant) {
Add-BoxToVagrant -vagrantBoxName $fullConfigName -packedBoxPath $packedBoxPath -force:$force -whatif:$whatif

@ -128,7 +128,7 @@
<SynchronousCommand wcm:action="add">
<!-- This task MUST include enabling winrm for Packer to be able to continue -->
<CommandLine>powershell.exe -File A:\autounattend-postinstall.ps1</CommandLine>
<CommandLine>powershell.exe -File A:\autounattend-postinstall.ps1 -SkipWindowsUpdates</CommandLine>
<Description>Run Postinstall Script</Description>
<Order>99</Order>
<RequiresUserInput>true</RequiresUserInput>

@ -39,6 +39,6 @@ Invoke-ScriptblockAndCatch -scriptBlock {
}
Set-UserOptions @suoParams
Install-CompiledDotNetAssemblies # Takes about 15 minutes for me
Compress-WindowsInstall # Takes maybe another 15 minutes
#Install-CompiledDotNetAssemblies # Takes about 15 minutes for me
#Compress-WindowsInstall # Takes maybe another 15 minutes
}

@ -186,7 +186,7 @@ function Invoke-ScriptblockAndCatch {
Invoke-Command $scriptBlock
}
catch {
Write-ErrorStackToEventLog -errorStack $_
Write-ErrorStackToEventLog -errorStack $error
exit $failureExitCode
}
}
@ -415,20 +415,20 @@ function Install-CompiledDotNetAssemblies {
# http://robrelyea.wordpress.com/2007/07/13/may-be-helpful-ngen-exe-executequeueditems/
# Don't check the return value - sometimes it fails and that's fine
$ngen32 = "${env:WinDir}\microsoft.net\framework\v4.0.30319\ngen.exe"
Invoke-ExpressionEx "$ngen32 update /force /queue"
Invoke-ExpressionEx "$ngen32 executequeueditems"
# set-alias ngen32 "${env:WinDir}\microsoft.net\framework\v4.0.30319\ngen.exe"
# ngen32 update /force /queue
# ngen32 executequeueditems
$ngen32path = "${env:WinDir}\microsoft.net\framework\v4.0.30319\ngen.exe"
# Invoke-ExpressionEx "$ngen32path update /force /queue"
# Invoke-ExpressionEx "$ngen32path executequeueditems"
set-alias ngen32 $ngen32path
ngen32 update /force /queue
ngen32 executequeueditems
if ((Get-OSArchitecture) -match $ArchitectureId.amd64) {
# set-alias ngen64 "${env:WinDir}\microsoft.net\framework64\v4.0.30319\ngen.exe"
# ngen64 update /force /queue
# ngen64 executequeueditems
$ngen64 = "${env:WinDir}\microsoft.net\framework64\v4.0.30319\ngen.exe"
Invoke-ExpressionEx "$ngen64 update /force /queue"
Invoke-ExpressionEx "$ngen64 executequeueditems"
$ngen64path = "${env:WinDir}\microsoft.net\framework64\v4.0.30319\ngen.exe"
# Invoke-ExpressionEx "$ngen64path update /force /queue"
# Invoke-ExpressionEx "$ngen64path executequeueditems"
set-alias ngen64 $ngen64path
ngen64 update /force /queue
ngen64 executequeueditems
}
}
@ -438,19 +438,19 @@ function Compress-WindowsInstall {
$udfZipPath = Get-WebUrl -url $URLs.UltraDefragDownload.$OSArch -outDir $env:temp
$udfExPath = "${env:temp}\ultradefrag-portable-6.1.0.$OSArch"
# This archive contains a folder - extract it directly to the temp dir
Invoke-ExpressionEx -checkExitCode -command ('sevenzip x "{0}" "-o{1}"' -f $udfZipPath,$env:temp)
Invoke-ExpressionEx -command ('sevenzip x "{0}" "-o{1}"' -f $udfZipPath,$env:temp)
$sdZipPath = Get-WebUrl -url $URLs.SdeleteDownload -outDir $env:temp
$sdExPath = "${env:temp}\SDelete"
# This archive does NOT contain a folder - extract it to a subfolder (will create if necessary)
Invoke-ExpressionEx -checkExitCode -command ('sevenzip x "{0}" "-o{1}"' -f $sdZipPath,$sdExPath)
Invoke-ExpressionEx -command ('sevenzip x "{0}" "-o{1}"' -f $sdZipPath,$sdExPath)
stop-service wuauserv
rm -recurse -force ${env:WinDir}\SoftwareDistribution\Download
start-service wuauserv
Invoke-ExpressionEx -checkExitCode -logToStdout -command ('& {0} --optimize --repeat "{1}"' -f "$udfExPath\udefrag.exe","$env:SystemDrive")
Invoke-ExpressionEx -checkExitCode -command ('& {0} /accepteula -q -z "{1}"' -f "$sdExPath\SDelete.exe",$env:SystemDrive)
Invoke-ExpressionEx -logToStdout -command ('& {0} --optimize --repeat "{1}"' -f "$udfExPath\udefrag.exe","$env:SystemDrive")
Invoke-ExpressionEx -command ('& {0} /accepteula -q -z "{1}"' -f "$sdExPath\SDelete.exe",$env:SystemDrive)
}
finally {
rm -recurse -force $udfZipPath,$udfExPath,$sdZipPath,$sdExPath -ErrorAction Continue

@ -12,7 +12,8 @@ thisVagrantfileDir = File.dirname(__FILE__)
commonScriptsDir = "#{thisVagrantfileDir}/../../scripts"
Vagrant.configure("2") do |config|
config.vm.define "FreyjaA " + DateTime.now.strftime("%Y-%m-%d-%H-%M-%S")
#config.vm.define "FreyjaA " + DateTime.now.strftime("%Y-%m-%d-%H-%M-%S")
config.vm.define "FreyjaA-2016-01-08"
#config.vm.box = "wintriallab-windows_10_x86"
config.vm.box = "wintriallab-windows_81_x86"
config.vm.communicator = "winrm"
@ -25,7 +26,8 @@ Vagrant.configure("2") do |config|
config.windows.halt_timeout = 15
#config.vm.network :forwarded_port, guest: 3389, host: 33891, id: "rdp", auto_correct: true
config.vm.network :bridged
#config.vm.network :bridged
config.vm.network "public_network"
config.vm.provider :virtualbox do |v, override|
#v.gui = true
@ -38,5 +40,15 @@ Vagrant.configure("2") do |config|
v.customize ["modifyvm", :id, "--draganddrop", "bidirectional"]
end
config.vm.provision "file", source: "#{commonScriptsDir}/wintriallab-postinstall.psm1", destination: "marionettist/wintriallab-postinstall.psm1"
begin
Dir.mkdir('./synced')
rescue
puts "./synced is already created I guess idk"
end
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder "./synced", "/vagrant", create: true
FileUtils.cp "#{commonScriptsDir}/wintriallab-postinstall.psm1", "./synced/wintriallab-postinstall.psm1"
FileUtils.cp "./provision-dlpvpns.ps1", "./synced/provision-dlpvpns.ps1"
config.vm.provision "shell", inline: "C:/vagrant/provision-dlpvpns.ps1"
end

@ -8,8 +8,8 @@ Vagrant.require_version ">= 1.6.2"
Vagrant.configure("2") do |config|
#config.vm.define "gheis-" + DateTime.now.strftime("%Y-%m-%d-%H-%M-%S")
config.vm.define "gheis-2015-11-20"
config.vm.box = "windows_10_x86_virtualbox.box"
config.vm.define "gheis-2016-02-05"
config.vm.box = "wintriallab-windows_10_x86"
config.vm.communicator = "winrm"
config.vm.hostname = "gheis"
@ -24,21 +24,25 @@ Vagrant.configure("2") do |config|
config.vm.network :forwarded_port, guest: 3389, host: 33389, id: "rdp", auto_correct: true
config.vm.provider :virtualbox do |v, override|
#v.gui = true
v.gui = true
v.customize ["modifyvm", :id, "--memory", 2048]
v.customize ["modifyvm", :id, "--cpus", 2]
v.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ]
#v.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ]
v.customize ["modifyvm", :id, "--accelerate2dvideo", "on"]
v.customize ["modifyvm", :id, "--vram", 128]
v.customize ["modifyvm", :id, "--clipboard", "bidirectional"]
v.customize ["modifyvm", :id, "--draganddrop", "bidirectional"]
end
Dir.mkdir('./synced')
begin
Dir.mkdir('./synced')
rescue
puts "./synced is already created I guess idk"
end
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder "./synced", "/vagrant", create: true
FileUtils.cp "../../scripts/wintriallab-postinstall.psm1" "./synced/"
FileUtils.cp "./bitchbox-postinstall.ps1" "./synced/"
FileUtils.cp "../../scripts/wintriallab-postinstall.psm1", "./synced/"
FileUtils.cp "./gheis-postinstall.ps1", "./synced/"
config.vm.provision "shell", inline: "C:/marionettist/bitchbox-postinstall.ps1"
config.vm.provision "shell", inline: "C:/marionettist/gheis-postinstall.ps1"
end
Loading…
Cancel
Save