- Add new script for building the Packer boxes called labbuilder.ps1 - Rearranged the hierarchy (my new script relies on the new hierarchy) - Working windows_81_x86 folder - Moved old packer-windows stuff to legacy-packer-windows directory. I plan to move it over piece by piece - Added a script to install 7zip that the other post install scripts can depend on - Fixed compact.bat & vm-guest-tools.bat to use 7zip installer - Fixed compact.bat to work with 32 bit machines - Added a readmejowjDev
parent
a37558518e
commit
1230ab9829
@ -0,0 +1,162 @@
|
||||
<#
|
||||
.synopsis
|
||||
Windows Trial lab management script
|
||||
.parameter baseConfigName
|
||||
The name of one of the subdirs like "windows_81_x86"
|
||||
.parameter action
|
||||
Which build actions do you want to perform?
|
||||
.parameter tag
|
||||
A tag for the temporary directory, the output directory, and the resulting Vagrant box
|
||||
#>
|
||||
[cmdletbinding()]
|
||||
param(
|
||||
[parameter(mandatory=$true)] [string] $baseConfigName,
|
||||
[parameter(mandatory=$true)] [string[]] $action,
|
||||
$baseOutDir = "D:\iso\vagrants",
|
||||
$packerCacheDir = "D:\iso\packer_cache",
|
||||
[string] $tag,
|
||||
[switch] $force,
|
||||
[switch] $whatIf
|
||||
)
|
||||
|
||||
$errorActionPreference = "Stop"
|
||||
#$dateStamp = get-date -UFormat "%Y-%m-%d-%H-%M-%S"
|
||||
#$fullConfigName = "wintriallab-${baseConfigName}-${dateStamp}"
|
||||
$fullConfigName = "wintriallab-${baseConfigName}"
|
||||
set-alias packer (gcm packer | select -expand path)
|
||||
set-alias vagrant (gcm vagrant | select -expand path)
|
||||
|
||||
$outDir = "${baseOutDir}\${fullConfigName}"
|
||||
if ($tag) { $outDir += "-${tag}"}
|
||||
|
||||
$packerConfigRoot = "${PSScriptRoot}\${baseConfigName}"
|
||||
$packerFile = "${packerConfigRoot}\${baseConfigName}.packerfile.json"
|
||||
$packedBoxPath = "${outDir}\${baseConfigName}_virtualbox.box"
|
||||
$vagrantTemplate = "${packerConfigRoot}\vagrantfile-${baseConfigName}.template"
|
||||
|
||||
function Build-PackerFile {
|
||||
[cmdletbinding()]
|
||||
param(
|
||||
[parameter(mandatory=$true)] $packerFile,
|
||||
[parameter(mandatory=$true)] $vagrantTemplate,
|
||||
[parameter(mandatory=$true)] [string] $vagrantBoxName,
|
||||
$tag,
|
||||
$packerCacheDir,
|
||||
$outDir,
|
||||
[switch] $force,
|
||||
[switch] $whatIf
|
||||
)
|
||||
|
||||
$packerFile = get-item $packerFile
|
||||
write-host $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'" }
|
||||
}
|
||||
|
||||
pushd (get-item $packerFile | select -expand fullname | split-path -parent)
|
||||
try {
|
||||
write-host "Building packer file '$($packerFile.fullname)' to directory '$outDir'..."
|
||||
if (-not $whatif) {
|
||||
packer build -var "output_directory=$outDir" "$($packerFile.fullname)"
|
||||
if ($LASTEXITCODE -ne 0) { throw "External command failed with code $LASTEXITCODE" }
|
||||
}
|
||||
}
|
||||
finally {
|
||||
popd
|
||||
}
|
||||
$outBox = get-item $outDir\*.box
|
||||
if ($outBox.count -gt 1) {
|
||||
throw "Somehow you came up with more than one box here: '$outBox'"
|
||||
}
|
||||
if ($outBox -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'"
|
||||
}
|
||||
|
||||
function Add-BoxToVagrant {
|
||||
[cmdletbinding()]
|
||||
param(
|
||||
[parameter(mandatory=$true)] $vagrantBoxName,
|
||||
[parameter(mandatory=$true)] $packedBoxPath,
|
||||
[switch] $whatIf
|
||||
)
|
||||
if (-not $whatIf) {
|
||||
vagrant box add --name $vagrantBoxName $packedBoxPath
|
||||
if ($LASTEXITCODE -ne 0) { throw "External command failed with code '$LASTEXITCODE'" }
|
||||
}
|
||||
}
|
||||
|
||||
function Run-VagrantBox {
|
||||
[cmdletbinding()]
|
||||
param(
|
||||
[parameter(mandatory=$true)] $vagrantBoxName,
|
||||
[parameter(mandatory=$true)] $workingDirectory, # with a Vagrantfile in it
|
||||
[switch] $whatIf
|
||||
)
|
||||
if (-not $whatIf) {
|
||||
try {
|
||||
pushd $workingDirectory
|
||||
vagrant up
|
||||
if ($LASTEXITCODE -ne 0) { throw "External command failed with code '$LASTEXITCODE'" }
|
||||
}
|
||||
finally {
|
||||
popd
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Show-LabVariable {
|
||||
param(
|
||||
[parameter(mandatory=$true)] [string] $varName,
|
||||
[switch] $testPath
|
||||
)
|
||||
$LabVariable = new-object PSObject -Property @{
|
||||
Variable = $varName
|
||||
Value = get-variable $varName | select -expand value
|
||||
PathExists = "-"
|
||||
}
|
||||
if ($testPath) { $LabVariable.PathExists = test-path $LabVariable.Value }
|
||||
return $LabVariable
|
||||
}
|
||||
|
||||
########
|
||||
|
||||
# Just always show this:
|
||||
#if ($action -contains "Info") {
|
||||
write-host ""
|
||||
##write-output "Non-path variables: "
|
||||
Show-LabVariable -varName 'fullConfigName'
|
||||
##write-output "`nPaths to files that SHOULD exist already: "
|
||||
Show-LabVariable packerConfigRoot -testPath
|
||||
Show-LabVariable packerFile -testPath
|
||||
Show-LabVariable vagrantTemplate -testPath
|
||||
##write-output "`nPaths to files that SHOULD NOT exist (unless you passed -force): "
|
||||
Show-LabVariable outDir -testPath
|
||||
Show-LabVariable packedBoxPath -testPath
|
||||
write-output ""
|
||||
#}
|
||||
|
||||
if ($action -contains "BuildPacker") {
|
||||
$bpfParam = @{
|
||||
packerFile = $packerFile
|
||||
vagrantTemplate = $vagrantTemplate
|
||||
vagrantBoxName = $fullConfigName
|
||||
tag = $tag
|
||||
packerCacheDir = $packerCacheDir
|
||||
outDir = $outDir
|
||||
force = $force
|
||||
whatIf = $whatIf
|
||||
}
|
||||
Build-PackerFile @bpfParam
|
||||
}
|
||||
if ($action -contains "AddToVagrant") {
|
||||
Add-BoxToVagrant -vagrantBoxName $fullConfigName -packedBoxPath $packedBoxPath
|
||||
}
|
||||
if ($action -contains "VagrantUp") {
|
||||
Run-VagrantBox -vagrantBoxName $fullConfigName -workingDirectory $outDir
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
[cmdletbinding()]
|
||||
param(
|
||||
[parameter(mandatory=$true)] [string] $packerFile,
|
||||
[string] $tag = "", # tag for the tmp dir, so you can keep track of what you were working on
|
||||
[switch] $whatIf
|
||||
)
|
||||
|
||||
$errorActionPreference = "Stop"
|
||||
|
||||
#$baseTempDir = $env:Temp
|
||||
$baseOutDir = "D:\iso\vagrants"
|
||||
$env_packer_cache_dir_backup = $env:PACKER_CACHE_DIR
|
||||
$env:PACKER_CACHE_DIR = "D:\iso\packer_cache"
|
||||
set-alias packer (gcm packer | select -expand path)
|
||||
set-alias vagrant (gcm vagrant | select -expand path)
|
||||
|
||||
$startDate = get-date
|
||||
$packerFilePath = get-item $packerFile | select -expand fullname
|
||||
$packerFileBaseName = get-item $packerFile | select -expand basename
|
||||
$date = get-date -date $startDate -UFormat "%Y-%m-%d-%H-%M-%S"
|
||||
$vagrantBoxName = "wintriallab-${packerFileBaseName}-${date}"
|
||||
|
||||
$outDir = "${baseOutDir}\${vagrantBoxName}"
|
||||
if ($tag) { $outDir += "-${tag}"}
|
||||
if (test-path $outDir) { throw "Your `$outDir that already exists at '$outDir'"}
|
||||
|
||||
pushd $PSScriptRoot
|
||||
try {
|
||||
write-host "Building packer file '$packerFilePath' to directory '$outDir'..."
|
||||
if (-not $whatif) {
|
||||
packer build -var "output_directory=$outDir" "$packerFilePath"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Packer appears to have failed :("
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
popd
|
||||
$env:PACKER_CACHE_DIR = $env_packer_cache_dir_backup
|
||||
}
|
||||
$packedBoxPath = get-item $outDir\*.box | select -first 1 -expand fullname
|
||||
write-host "Packed .box file: '$packedBoxPath'"
|
||||
|
||||
if ($vagrantAdd) {
|
||||
if (-not $whatIf) {
|
||||
vagrant box add --name $vagrantBoxName $packedBoxPath
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
*.exe
|
||||
*.msi
|
||||
*.msu
|
@ -0,0 +1,6 @@
|
||||
if not exist "C:\Windows\Temp\chef.msi" (
|
||||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://www.getchef.com/chef/install.msi', 'C:\Windows\Temp\chef.msi')" <NUL
|
||||
)
|
||||
|
||||
msiexec /qb /i C:\Windows\Temp\chef.msi
|
||||
powershell -Command "Start-Sleep 1" <NUL
|
@ -0,0 +1,22 @@
|
||||
$chocoExePath = 'C:\ProgramData\Chocolatey\bin'
|
||||
|
||||
if ($($env:Path).ToLower().Contains($($chocoExePath).ToLower())) {
|
||||
echo "Chocolatey found in PATH, skipping install..."
|
||||
Exit
|
||||
}
|
||||
|
||||
# Add to system PATH
|
||||
$systemPath = [Environment]::GetEnvironmentVariable('Path',[System.EnvironmentVariableTarget]::Machine)
|
||||
$systemPath += ';' + $chocoExePath
|
||||
[Environment]::SetEnvironmentVariable("PATH", $systemPath, [System.EnvironmentVariableTarget]::Machine)
|
||||
|
||||
# Update local process' path
|
||||
$userPath = [Environment]::GetEnvironmentVariable('Path',[System.EnvironmentVariableTarget]::User)
|
||||
if($userPath) {
|
||||
$env:Path = $systemPath + ";" + $userPath
|
||||
} else {
|
||||
$env:Path = $systemPath
|
||||
}
|
||||
|
||||
# Run the installer
|
||||
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
|
@ -0,0 +1,32 @@
|
||||
if not exist "C:\Windows\Temp\7z920-x64.msi" (
|
||||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://www.7-zip.org/a/7z920-x64.msi', 'C:\Windows\Temp\7z920-x64.msi')" <NUL
|
||||
)
|
||||
msiexec /qb /i C:\Windows\Temp\7z920-x64.msi
|
||||
|
||||
if not exist "C:\Windows\Temp\ultradefrag.zip" (
|
||||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://downloads.sourceforge.net/project/ultradefrag/stable-release/6.1.0/ultradefrag-portable-6.1.0.bin.amd64.zip', 'C:\Windows\Temp\ultradefrag.zip')" <NUL
|
||||
)
|
||||
|
||||
if not exist "C:\Windows\Temp\ultradefrag-portable-6.1.0.amd64\udefrag.exe" (
|
||||
cmd /c ""C:\Program Files\7-Zip\7z.exe" x C:\Windows\Temp\ultradefrag.zip -oC:\Windows\Temp"
|
||||
)
|
||||
|
||||
if not exist "C:\Windows\Temp\SDelete.zip" (
|
||||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://download.sysinternals.com/files/SDelete.zip', 'C:\Windows\Temp\SDelete.zip')" <NUL
|
||||
)
|
||||
|
||||
if not exist "C:\Windows\Temp\sdelete.exe" (
|
||||
cmd /c ""C:\Program Files\7-Zip\7z.exe" x C:\Windows\Temp\SDelete.zip -oC:\Windows\Temp"
|
||||
)
|
||||
|
||||
msiexec /qb /x C:\Windows\Temp\7z920-x64.msi
|
||||
|
||||
net stop wuauserv
|
||||
rmdir /S /Q C:\Windows\SoftwareDistribution\Download
|
||||
mkdir C:\Windows\SoftwareDistribution\Download
|
||||
net start wuauserv
|
||||
|
||||
cmd /c C:\Windows\Temp\ultradefrag-portable-6.1.0.amd64\udefrag.exe --optimize --repeat C:
|
||||
|
||||
cmd /c %SystemRoot%\System32\reg.exe ADD HKCU\Software\Sysinternals\SDelete /v EulaAccepted /t REG_DWORD /d 1 /f
|
||||
cmd /c C:\Windows\Temp\sdelete.exe -q -z C:
|
@ -0,0 +1,15 @@
|
||||
::http://support.microsoft.com/kb/2570538
|
||||
::http://robrelyea.wordpress.com/2007/07/13/may-be-helpful-ngen-exe-executequeueditems/
|
||||
|
||||
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto 64BIT
|
||||
|
||||
%windir%\microsoft.net\framework\v4.0.30319\ngen.exe update /force /queue
|
||||
%windir%\microsoft.net\framework\v4.0.30319\ngen.exe executequeueditems
|
||||
|
||||
exit /b
|
||||
|
||||
:64BIT
|
||||
%windir%\microsoft.net\framework\v4.0.30319\ngen.exe update /force /queue
|
||||
%windir%\microsoft.net\framework64\v4.0.30319\ngen.exe update /force /queue
|
||||
%windir%\microsoft.net\framework\v4.0.30319\ngen.exe executequeueditems
|
||||
%windir%\microsoft.net\framework64\v4.0.30319\ngen.exe executequeueditems
|
@ -0,0 +1,30 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Disables automatic windows updates
|
||||
.DESCRIPTION
|
||||
Disables checking for and applying Windows Updates (does not prevent updates from being applied manually or being pushed down)
|
||||
Run on the machine that updates need disabling on.
|
||||
.PARAMETER <paramName>
|
||||
None
|
||||
.EXAMPLE
|
||||
./Disable-WindowsUpdates.ps1
|
||||
#>
|
||||
$RunningAsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
|
||||
if ($RunningAsAdmin)
|
||||
{
|
||||
|
||||
$Updates = (New-Object -ComObject "Microsoft.Update.AutoUpdate").Settings
|
||||
|
||||
if ($Updates.ReadOnly -eq $True) { Write-Error "Cannot update Windows Update settings due to GPO restrictions." }
|
||||
|
||||
else {
|
||||
$Updates.NotificationLevel = 1 #Disabled
|
||||
$Updates.Save()
|
||||
$Updates.Refresh()
|
||||
Write-Output "Automatic Windows Updates disabled."
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{ Write-Warning "Must be executed in Administrator level shell."
|
||||
Write-Warning "Script Cancelled!" }
|
@ -0,0 +1 @@
|
||||
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /d 0 /f
|
@ -0,0 +1,2 @@
|
||||
netsh advfirewall firewall add rule name="Open Port 3389" dir=in action=allow protocol=TCP localport=3389
|
||||
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
|
@ -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()
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
:: Windows 8 / Windows 2012 require KB2842230 hotfix
|
||||
:: The Windows Remote Management (WinRM) service does not use the customized value of the MaxMemoryPerShellMB quota.
|
||||
:: Instead, the WinRM service uses the default value, which is 150 MB.
|
||||
:: http://hotfixv4.microsoft.com/Windows%208%20RTM/nosp/Fix452763/9200/free/463941_intl_x64_zip.exe
|
||||
|
||||
@echo off
|
||||
set hotfix="C:\Windows\Temp\Windows8-RT-KB2842230-x64.msu"
|
||||
if not exist %hotfix% goto :eof
|
||||
|
||||
:: get windows version
|
||||
for /f "tokens=2 delims=[]" %%G in ('ver') do (set _version=%%G)
|
||||
for /f "tokens=2,3,4 delims=. " %%G in ('echo %_version%') do (set _major=%%G& set _minor=%%H& set _build=%%I)
|
||||
|
||||
:: 6.2 or 6.3
|
||||
if %_major% neq 6 goto :eof
|
||||
if %_minor% lss 2 goto :eof
|
||||
if %_minor% gtr 3 goto :eof
|
||||
|
||||
@echo on
|
||||
start /wait wusa "%hotfix%" /quiet /norestart
|
@ -0,0 +1,12 @@
|
||||
net stop wuauserv
|
||||
|
||||
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v EnableFeaturedSoftware /t REG_DWORD /d 1 /f
|
||||
|
||||
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v IncludeRecommendedUpdates /t REG_DWORD /d 1 /f
|
||||
|
||||
echo Set ServiceManager = CreateObject("Microsoft.Update.ServiceManager") > A:\temp.vbs
|
||||
echo Set NewUpdateService = ServiceManager.AddService2("7971f918-a847-4430-9279-4a52d1efe18d",7,"") >> A:\temp.vbs
|
||||
|
||||
cscript A:\temp.vbs
|
||||
|
||||
net start wuauserv
|
@ -0,0 +1,87 @@
|
||||
param (
|
||||
[switch]$AutoStart = $false
|
||||
)
|
||||
|
||||
Write-Output "AutoStart: $AutoStart"
|
||||
$is_64bit = [IntPtr]::size -eq 8
|
||||
|
||||
# setup openssh
|
||||
$ssh_download_url = "http://www.mls-software.com/files/setupssh-6.7p1-2.exe"
|
||||
|
||||
if (!(Test-Path "C:\Program Files\OpenSSH\bin\ssh.exe")) {
|
||||
Write-Output "Downloading $ssh_download_url"
|
||||
(New-Object System.Net.WebClient).DownloadFile($ssh_download_url, "C:\Windows\Temp\openssh.exe")
|
||||
|
||||
# initially set the port to 2222 so that there is not a race
|
||||
# condition in which packer connects to SSH before we can disable the service
|
||||
Start-Process "C:\Windows\Temp\openssh.exe" "/S /port=2222 /privsep=1 /password=D@rj33l1ng" -NoNewWindow -Wait
|
||||
}
|
||||
|
||||
Stop-Service "OpenSSHd" -Force
|
||||
|
||||
# ensure vagrant can log in
|
||||
Write-Output "Setting vagrant user file permissions"
|
||||
New-Item -ItemType Directory -Force -Path "C:\Users\vagrant\.ssh"
|
||||
C:\Windows\System32\icacls.exe "C:\Users\vagrant" /grant "vagrant:(OI)(CI)F"
|
||||
C:\Windows\System32\icacls.exe "C:\Program Files\OpenSSH\bin" /grant "vagrant:(OI)RX"
|
||||
C:\Windows\System32\icacls.exe "C:\Program Files\OpenSSH\usr\sbin" /grant "vagrant:(OI)RX"
|
||||
|
||||
Write-Output "Setting SSH home directories"
|
||||
(Get-Content "C:\Program Files\OpenSSH\etc\passwd") |
|
||||
Foreach-Object { $_ -replace '/home/(\w+)', '/cygdrive/c/Users/$1' } |
|
||||
Set-Content 'C:\Program Files\OpenSSH\etc\passwd'
|
||||
|
||||
# Set shell to /bin/sh to return exit status
|
||||
$passwd_file = Get-Content 'C:\Program Files\OpenSSH\etc\passwd'
|
||||
$passwd_file = $passwd_file -replace '/bin/bash', '/bin/sh'
|
||||
Set-Content 'C:\Program Files\OpenSSH\etc\passwd' $passwd_file
|
||||
|
||||
# fix opensshd to not be strict
|
||||
Write-Output "Setting OpenSSH to be non-strict"
|
||||
$sshd_config = Get-Content "C:\Program Files\OpenSSH\etc\sshd_config"
|
||||
$sshd_config = $sshd_config -replace 'StrictModes yes', 'StrictModes no'
|
||||
$sshd_config = $sshd_config -replace '#PubkeyAuthentication yes', 'PubkeyAuthentication yes'
|
||||
$sshd_config = $sshd_config -replace '#PermitUserEnvironment no', 'PermitUserEnvironment yes'
|
||||
# disable the use of DNS to speed up the time it takes to establish a connection
|
||||
$sshd_config = $sshd_config -replace '#UseDNS yes', 'UseDNS no'
|
||||
# disable the login banner
|
||||
$sshd_config = $sshd_config -replace 'Banner /etc/banner.txt', '#Banner /etc/banner.txt'
|
||||
# next time OpenSSH starts have it listen on th eproper port
|
||||
$sshd_config = $sshd_config -replace 'Port 2222', "Port 22"
|
||||
Set-Content "C:\Program Files\OpenSSH\etc\sshd_config" $sshd_config
|
||||
|
||||
Write-Output "Removing ed25519 key as Vagrant net-ssh 2.9.1 does not support it"
|
||||
Remove-Item -Force -ErrorAction SilentlyContinue "C:\Program Files\OpenSSH\etc\ssh_host_ed25519_key"
|
||||
Remove-Item -Force -ErrorAction SilentlyContinue "C:\Program Files\OpenSSH\etc\ssh_host_ed25519_key.pub"
|
||||
|
||||
# use c:\Windows\Temp as /tmp location
|
||||
Write-Output "Setting temp directory location"
|
||||
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "C:\Program Files\OpenSSH\tmp"
|
||||
C:\Program` Files\OpenSSH\bin\junction.exe /accepteula "C:\Program Files\OpenSSH\tmp" "C:\Windows\Temp"
|
||||
C:\Windows\System32\icacls.exe "C:\Windows\Temp" /grant "vagrant:(OI)(CI)F"
|
||||
|
||||
# add 64 bit environment variables missing from SSH
|
||||
Write-Output "Setting SSH environment"
|
||||
$sshenv = "TEMP=C:\Windows\Temp"
|
||||
if ($is_64bit) {
|
||||
$env_vars = "ProgramFiles(x86)=C:\Program Files (x86)", `
|
||||
"ProgramW6432=C:\Program Files", `
|
||||
"CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files", `
|
||||
"CommonProgramW6432=C:\Program Files\Common Files"
|
||||
$sshenv = $sshenv + "`r`n" + ($env_vars -join "`r`n")
|
||||
}
|
||||
Set-Content C:\Users\vagrant\.ssh\environment $sshenv
|
||||
|
||||
# record the path for provisioners (without the newline)
|
||||
Write-Output "Recording PATH for provisioners"
|
||||
Set-Content C:\Windows\Temp\PATH ([byte[]][char[]] $env:PATH) -Encoding Byte
|
||||
|
||||
# configure firewall
|
||||
Write-Output "Configuring firewall"
|
||||
netsh advfirewall firewall add rule name="SSHD" dir=in action=allow service=OpenSSHd enable=yes
|
||||
netsh advfirewall firewall add rule name="SSHD" dir=in action=allow program="C:\Program Files\OpenSSH\usr\sbin\sshd.exe" enable=yes
|
||||
netsh advfirewall firewall add rule name="ssh" dir=in action=allow protocol=TCP localport=22
|
||||
|
||||
if ($AutoStart -eq $true) {
|
||||
Start-Service "OpenSSHd"
|
||||
}
|
Binary file not shown.
@ -0,0 +1,10 @@
|
||||
if not exist "C:\Windows\Temp\puppet.msi" (
|
||||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://pm.puppetlabs.com/puppet-enterprise/3.0.1/puppet-enterprise-3.0.1.msi', 'C:\Windows\Temp\puppet.msi')" <NUL
|
||||
)
|
||||
|
||||
:: http://docs.puppetlabs.com/pe/latest/install_windows.html
|
||||
msiexec /qn /i C:\Windows\Temp\puppet.msi /log C:\Windows\Temp\puppet.log
|
||||
|
||||
<nul set /p ".=;C:\Program Files (x86)\Puppet Labs\Puppet Enterprise\bin" >> C:\Windows\Temp\PATH
|
||||
set /p PATH=<C:\Windows\Temp\PATH
|
||||
setx PATH "%PATH%" /m
|
@ -0,0 +1,10 @@
|
||||
if not exist "C:\Windows\Temp\puppet.msi" (
|
||||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://downloads.puppetlabs.com/windows/puppet-3.6.2.msi', 'C:\Windows\Temp\puppet.msi')" <NUL
|
||||
)
|
||||
|
||||
:: http://docs.puppetlabs.com/pe/latest/install_windows.html
|
||||
msiexec /qn /i C:\Windows\Temp\puppet.msi /log C:\Windows\Temp\puppet.log
|
||||
|
||||
<nul set /p ".=;C:\Program Files (x86)\Puppet Labs\Puppet\bin" >> C:\Windows\Temp\PATH
|
||||
set /p PATH=<C:\Windows\Temp\PATH
|
||||
setx PATH "%PATH%" /m
|
@ -0,0 +1,19 @@
|
||||
rem install rsync
|
||||
if not exist "C:\Windows\Temp\7z920-x64.msi" (
|
||||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://www.7-zip.org/a/7z920-x64.msi', 'C:\Windows\Temp\7z920-x64.msi')" <NUL
|
||||
)
|
||||
msiexec /qb /i C:\Windows\Temp\7z920-x64.msi
|
||||
|
||||
pushd C:\Windows\Temp
|
||||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://mirrors.kernel.org/sourceware/cygwin/x86_64/release/rsync/rsync-3.1.0-1.tar.xz', 'C:\Windows\Temp\rsync-3.1.0-1.tar.xz')" <NUL
|
||||
cmd /c ""C:\Program Files\7-Zip\7z.exe" x rsync-3.1.0-1.tar.xz"
|
||||
cmd /c ""C:\Program Files\7-Zip\7z.exe" x rsync-3.1.0-1.tar"
|
||||
copy /Y usr\bin\rsync.exe "C:\Program Files\OpenSSH\bin\rsync.exe"
|
||||
rmdir /s /q usr
|
||||
del rsync-3.1.0-1.tar
|
||||
popd
|
||||
|
||||
msiexec /qb /x C:\Windows\Temp\7z920-x64.msi
|
||||
|
||||
rem make symlink for c:/vagrant share
|
||||
mklink /D "C:\Program Files\OpenSSH\vagrant" "C:\vagrant"
|
@ -0,0 +1,11 @@
|
||||
if not exist "C:\Windows\Temp\salt64.exe" (
|
||||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://docs.saltstack.com/downloads/Salt-Minion-2014.1.3-1-AMD64-Setup.exe', 'C:\Windows\Temp\salt64.exe')" <NUL
|
||||
)
|
||||
|
||||
:: http://docs.saltstack.com/en/latest/topics/installation/windows.html
|
||||
c:\windows\temp\salt64.exe /S
|
||||
:: /master=<yoursaltmaster> /minion-name=<thisminionname>
|
||||
|
||||
<nul set /p ".=;C:\salt" >> C:\Windows\Temp\PATH
|
||||
set /p PATH=<C:\Windows\Temp\PATH
|
||||
setx PATH "%PATH%" /m
|
@ -0,0 +1,6 @@
|
||||
:: vagrant public key
|
||||
if exist a:\vagrant.pub (
|
||||
copy a:\vagrant.pub C:\Users\vagrant\.ssh\authorized_keys
|
||||
) else (
|
||||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub', 'C:\Users\vagrant\.ssh\authorized_keys')" <NUL
|
||||
)
|
@ -0,0 +1,51 @@
|
||||
if not exist "C:\Windows\Temp\7z920-x64.msi" (
|
||||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://www.7-zip.org/a/7z920-x64.msi', 'C:\Windows\Temp\7z920-x64.msi')" <NUL
|
||||
)
|
||||
msiexec /qb /i C:\Windows\Temp\7z920-x64.msi
|
||||
|
||||
if "%PACKER_BUILDER_TYPE%" equ "vmware-iso" goto :vmware
|
||||
if "%PACKER_BUILDER_TYPE%" equ "virtualbox-iso" goto :virtualbox
|
||||
if "%PACKER_BUILDER_TYPE%" equ "parallels-iso" goto :parallels
|
||||
goto :done
|
||||
|
||||
:vmware
|
||||
|
||||
if exist "C:\Users\vagrant\windows.iso" (
|
||||
move /Y C:\Users\vagrant\windows.iso C:\Windows\Temp
|
||||
)
|
||||
|
||||
if not exist "C:\Windows\Temp\windows.iso" (
|
||||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://softwareupdate.vmware.com/cds/vmw-desktop/ws/11.1.2/2780323/windows/packages/tools-windows-9.9.3.exe.tar', 'C:\Windows\Temp\vmware-tools.exe.tar')" <NUL
|
||||
cmd /c ""C:\Program Files\7-Zip\7z.exe" x C:\Windows\Temp\vmware-tools.exe.tar -oC:\Windows\Temp"
|
||||
FOR /r "C:\Windows\Temp" %%a in (tools-windows-*.exe) DO REN "%%~a" "tools-windows.exe"
|
||||
cmd /c C:\Windows\Temp\tools-windows
|
||||
move /Y "C:\Program Files (x86)\VMware\tools-windows\windows.iso" C:\Windows\Temp
|
||||
rd /S /Q "C:\Program Files (x86)\VMWare"
|
||||
)
|
||||
|
||||
cmd /c ""C:\Program Files\7-Zip\7z.exe" x "C:\Windows\Temp\windows.iso" -oC:\Windows\Temp\VMWare"
|
||||
cmd /c C:\Windows\Temp\VMWare\setup.exe /S /v"/qn REBOOT=R\"
|
||||
|
||||
goto :done
|
||||
|
||||
:virtualbox
|
||||
|
||||
:: There needs to be Oracle CA (Certificate Authority) certificates installed in order
|
||||
:: to prevent user intervention popups which will undermine a silent installation.
|
||||
cmd /c certutil -addstore -f "TrustedPublisher" A:\oracle-cert.cer
|
||||
|
||||
move /Y C:\Users\vagrant\VBoxGuestAdditions.iso C:\Windows\Temp
|
||||
cmd /c ""C:\Program Files\7-Zip\7z.exe" x C:\Windows\Temp\VBoxGuestAdditions.iso -oC:\Windows\Temp\virtualbox"
|
||||
cmd /c C:\Windows\Temp\virtualbox\VBoxWindowsAdditions.exe /S
|
||||
goto :done
|
||||
|
||||
:parallels
|
||||
if exist "C:\Users\vagrant\prl-tools-win.iso" (
|
||||
move /Y C:\Users\vagrant\prl-tools-win.iso C:\Windows\Temp
|
||||
cmd /C "C:\Program Files\7-Zip\7z.exe" x C:\Windows\Temp\prl-tools-win.iso -oC:\Windows\Temp\parallels
|
||||
cmd /C C:\Windows\Temp\parallels\PTAgent.exe /install_silent
|
||||
rd /S /Q "c:\Windows\Temp\parallels"
|
||||
)
|
||||
|
||||
:done
|
||||
msiexec /qb /x C:\Windows\Temp\7z920-x64.msi
|
@ -0,0 +1,233 @@
|
||||
param($global:RestartRequired=0,
|
||||
$global:MoreUpdates=0,
|
||||
$global:MaxCycles=5,
|
||||
$MaxUpdatesPerCycle=500)
|
||||
|
||||
$Logfile = "C:\Windows\Temp\win-updates.log"
|
||||
|
||||
function LogWrite {
|
||||
Param ([string]$logstring)
|
||||
$now = Get-Date -format s
|
||||
Add-Content $Logfile -value "$now $logstring"
|
||||
Write-Host $logstring
|
||||
}
|
||||
|
||||
function Check-ContinueRestartOrEnd() {
|
||||
$RegistryKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
|
||||
$RegistryEntry = "InstallWindowsUpdates"
|
||||
switch ($global:RestartRequired) {
|
||||
0 {
|
||||
$prop = (Get-ItemProperty $RegistryKey).$RegistryEntry
|
||||
if ($prop) {
|
||||
LogWrite "Restart Registry Entry Exists - Removing It"
|
||||
Remove-ItemProperty -Path $RegistryKey -Name $RegistryEntry -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
LogWrite "No Restart Required"
|
||||
Check-WindowsUpdates
|
||||
|
||||
if (($global:MoreUpdates -eq 1) -and ($script:Cycles -le $global:MaxCycles)) {
|
||||
Install-WindowsUpdates
|
||||
} elseif ($script:Cycles -gt $global:MaxCycles) {
|
||||
LogWrite "Exceeded Cycle Count - Stopping"
|
||||
Invoke-Expression "a:\openssh.ps1 -AutoStart"
|
||||
} else {
|
||||
LogWrite "Done Installing Windows Updates"
|
||||
Invoke-Expression "a:\openssh.ps1 -AutoStart"
|
||||
}
|
||||
}
|
||||
1 {
|
||||
$prop = (Get-ItemProperty $RegistryKey).$RegistryEntry
|
||||
if (-not $prop) {
|
||||
LogWrite "Restart Registry Entry Does Not Exist - Creating It"
|
||||
Set-ItemProperty -Path $RegistryKey -Name $RegistryEntry -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File $($script:ScriptPath) -MaxUpdatesPerCycle $($MaxUpdatesPerCycle)"
|
||||
} else {
|
||||
LogWrite "Restart Registry Entry Exists Already"
|
||||
}
|
||||
|
||||
LogWrite "Restart Required - Restarting..."
|
||||
Restart-Computer
|
||||
}
|
||||
default {
|
||||
LogWrite "Unsure If A Restart Is Required"
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Install-WindowsUpdates() {
|
||||
$script:Cycles++
|
||||
LogWrite "Evaluating Available Updates with limit of $($MaxUpdatesPerCycle):"
|
||||
$UpdatesToDownload = New-Object -ComObject 'Microsoft.Update.UpdateColl'
|
||||
$script:i = 0;
|
||||
$CurrentUpdates = $SearchResult.Updates
|
||||
while($script:i -lt $CurrentUpdates.Count -and $script:CycleUpdateCount -lt $MaxUpdatesPerCycle) {
|
||||
$Update = $CurrentUpdates.Item($script:i)
|
||||
if (($Update -ne $null) -and (!$Update.IsDownloaded)) {
|
||||
[bool]$addThisUpdate = $false
|
||||
if ($Update.InstallationBehavior.CanRequestUserInput) {
|
||||
LogWrite "> Skipping: $($Update.Title) because it requires user input"
|
||||
} else {
|
||||
if (!($Update.EulaAccepted)) {
|
||||
LogWrite "> Note: $($Update.Title) has a license agreement that must be accepted. Accepting the license."
|
||||
$Update.AcceptEula()
|
||||
[bool]$addThisUpdate = $true
|
||||
$script:CycleUpdateCount++
|
||||
} else {
|
||||
[bool]$addThisUpdate = $true
|
||||
$script:CycleUpdateCount++
|
||||
}
|
||||
}
|
||||
|
||||
if ([bool]$addThisUpdate) {
|
||||
LogWrite "Adding: $($Update.Title)"
|
||||
$UpdatesToDownload.Add($Update) |Out-Null
|
||||
}
|
||||
}
|
||||
$script:i++
|
||||
}
|
||||
|
||||
if ($UpdatesToDownload.Count -eq 0) {
|
||||
LogWrite "No Updates To Download..."
|
||||
} else {
|
||||
LogWrite 'Downloading Updates...'
|
||||
$ok = 0;
|
||||
while (! $ok) {
|
||||
try {
|
||||
$Downloader = $UpdateSession.CreateUpdateDownloader()
|
||||
$Downloader.Updates = $UpdatesToDownload
|
||||
$Downloader.Download()
|
||||
$ok = 1;
|
||||
} catch {
|
||||
LogWrite $_.Exception | Format-List -force
|
||||
LogWrite "Error downloading updates. Retrying in 30s."
|
||||
$script:attempts = $script:attempts + 1
|
||||
Start-Sleep -s 30
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$UpdatesToInstall = New-Object -ComObject 'Microsoft.Update.UpdateColl'
|
||||
[bool]$rebootMayBeRequired = $false
|
||||
LogWrite 'The following updates are downloaded and ready to be installed:'
|
||||
foreach ($Update in $SearchResult.Updates) {
|
||||
if (($Update.IsDownloaded)) {
|
||||
LogWrite "> $($Update.Title)"
|
||||
$UpdatesToInstall.Add($Update) |Out-Null
|
||||
|
||||
if ($Update.InstallationBehavior.RebootBehavior -gt 0){
|
||||
[bool]$rebootMayBeRequired = $true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($UpdatesToInstall.Count -eq 0) {
|
||||
LogWrite 'No updates available to install...'
|
||||
$global:MoreUpdates=0
|
||||
$global:RestartRequired=0
|
||||
Invoke-Expression "a:\openssh.ps1 -AutoStart"
|
||||
break
|
||||
}
|
||||
|
||||
if ($rebootMayBeRequired) {
|
||||
LogWrite 'These updates may require a reboot'
|
||||
$global:RestartRequired=1
|
||||
}
|
||||
|
||||
LogWrite 'Installing updates...'
|
||||
|
||||
$Installer = $script:UpdateSession.CreateUpdateInstaller()
|
||||
$Installer.Updates = $UpdatesToInstall
|
||||
$InstallationResult = $Installer.Install()
|
||||
|
||||
LogWrite "Installation Result: $($InstallationResult.ResultCode)"
|
||||
LogWrite "Reboot Required: $($InstallationResult.RebootRequired)"
|
||||
LogWrite 'Listing of updates installed and individual installation results:'
|
||||
if ($InstallationResult.RebootRequired) {
|
||||
$global:RestartRequired=1
|
||||
} else {
|
||||
$global:RestartRequired=0
|
||||
}
|
||||
|
||||
for($i=0; $i -lt $UpdatesToInstall.Count; $i++) {
|
||||
New-Object -TypeName PSObject -Property @{
|
||||
Title = $UpdatesToInstall.Item($i).Title
|
||||
Result = $InstallationResult.GetUpdateResult($i).ResultCode
|
||||
}
|
||||
LogWrite "Item: " $UpdatesToInstall.Item($i).Title
|
||||
LogWrite "Result: " $InstallationResult.GetUpdateResult($i).ResultCode;
|
||||
}
|
||||
|
||||
Check-ContinueRestartOrEnd
|
||||
}
|
||||
|
||||
function Check-WindowsUpdates() {
|
||||
LogWrite "Checking For Windows Updates"
|
||||
$Username = $env:USERDOMAIN + "\" + $env:USERNAME
|
||||
|
||||
New-EventLog -Source $ScriptName -LogName 'Windows Powershell' -ErrorAction SilentlyContinue
|
||||
|
||||
$Message = "Script: " + $ScriptPath + "`nScript User: " + $Username + "`nStarted: " + (Get-Date).toString()
|
||||
|
||||
Write-EventLog -LogName 'Windows Powershell' -Source $ScriptName -EventID "104" -EntryType "Information" -Message $Message
|
||||
LogWrite $Message
|
||||
|
||||
$script:UpdateSearcher = $script:UpdateSession.CreateUpdateSearcher()
|
||||
$script:successful = $FALSE
|
||||
$script:attempts = 0
|
||||
$script:maxAttempts = 12
|
||||
while(-not $script:successful -and $script:attempts -lt $script:maxAttempts) {
|
||||
try {
|
||||
$script:SearchResult = $script:UpdateSearcher.Search("IsInstalled=0 and Type='Software' and IsHidden=0")
|
||||
$script:successful = $TRUE
|
||||
} catch {
|
||||
LogWrite $_.Exception | Format-List -force
|
||||
LogWrite "Search call to UpdateSearcher was unsuccessful. Retrying in 10s."
|
||||
$script:attempts = $script:attempts + 1
|
||||
Start-Sleep -s 10
|
||||
}
|
||||
}
|
||||
|
||||
if ($SearchResult.Updates.Count -ne 0) {
|
||||
$Message = "There are " + $SearchResult.Updates.Count + " more updates."
|
||||
LogWrite $Message
|
||||
try {
|
||||
for($i=0; $i -lt $script:SearchResult.Updates.Count; $i++) {
|
||||
LogWrite $script:SearchResult.Updates.Item($i).Title
|
||||
LogWrite $script:SearchResult.Updates.Item($i).Description
|
||||
LogWrite $script:SearchResult.Updates.Item($i).RebootRequired
|
||||
LogWrite $script:SearchResult.Updates.Item($i).EulaAccepted
|
||||
}
|
||||
$global:MoreUpdates=1
|
||||
} catch {
|
||||
LogWrite $_.Exception | Format-List -force
|
||||
LogWrite "Showing SearchResult was unsuccessful. Rebooting."
|
||||
$global:RestartRequired=1
|
||||
$global:MoreUpdates=0
|
||||
Check-ContinueRestartOrEnd
|
||||
LogWrite "Show never happen to see this text!"
|
||||
Restart-Computer
|
||||
}
|
||||
} else {
|
||||
LogWrite 'There are no applicable updates'
|
||||
$global:RestartRequired=0
|
||||
$global:MoreUpdates=0
|
||||
}
|
||||
}
|
||||
|
||||
$script:ScriptName = $MyInvocation.MyCommand.ToString()
|
||||
$script:ScriptPath = $MyInvocation.MyCommand.Path
|
||||
$script:UpdateSession = New-Object -ComObject 'Microsoft.Update.Session'
|
||||
$script:UpdateSession.ClientApplicationID = 'Packer Windows Update Installer'
|
||||
$script:UpdateSearcher = $script:UpdateSession.CreateUpdateSearcher()
|
||||
$script:SearchResult = New-Object -ComObject 'Microsoft.Update.UpdateColl'
|
||||
$script:Cycles = 0
|
||||
$script:CycleUpdateCount = 0
|
||||
|
||||
Check-WindowsUpdates
|
||||
if ($global:MoreUpdates -eq 1) {
|
||||
Install-WindowsUpdates
|
||||
} else {
|
||||
Check-ContinueRestartOrEnd
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
|
||||
Build a packer file:
|
||||
|
||||
buildlab -baseConfigName windows_81_x86 -action BuildPacker -tag "TestBuildForFun"
|
||||
|
||||
Add it to Vagrant
|
||||
|
||||
buildlab -baseConfigName windows_81_x86 -action AddToVagrant -tag "TestBuildForFun"
|
||||
|
||||
You can do both of these at once with
|
||||
|
||||
-action BuildPacker,AddToVagrant
|
||||
|
||||
More shit to come later
|
@ -1,32 +1,45 @@
|
||||
if not exist "C:\Windows\Temp\7z920-x64.msi" (
|
||||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://www.7-zip.org/a/7z920-x64.msi', 'C:\Windows\Temp\7z920-x64.msi')" <NUL
|
||||
set TEMPTEMP=C:\PackerTemp
|
||||
mkdir %TEMPTEMP%
|
||||
|
||||
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set OSARCHITECTURE=32BIT || set OSARCHITECTURE=64BIT
|
||||
echo OSARCHITECTURE == %OSARCHITECTURE%
|
||||
|
||||
set UDFARCH=i386
|
||||
if %OSARCHITECTURE%==64BIT set UDFARCH=amd64
|
||||
echo UDFARCH == %UDFARCH%
|
||||
|
||||
set UDFFILENAME=ultradefrag-portable-6.1.0.bin.%UDFARCH%.zip
|
||||
set UDFURL=http://downloads.sourceforge.net/project/ultradefrag/stable-release/6.1.0/%UDFFILENAME%
|
||||
set UDFZIP=%TEMPTEMP%\%UDFFILENAME%
|
||||
set UDFEXE=%TEMPTEMP%\ultradefrag-portable-6.1.0.%UDFARCH%\udefrag.exe
|
||||
|
||||
if not exist "%UDFZIP%" (
|
||||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%UDFURL%', '%UDFZIP%')" <NUL
|
||||
)
|
||||
msiexec /qb /i C:\Windows\Temp\7z920-x64.msi
|
||||
|
||||
if not exist "C:\Windows\Temp\ultradefrag.zip" (
|
||||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://downloads.sourceforge.net/project/ultradefrag/stable-release/6.1.0/ultradefrag-portable-6.1.0.bin.amd64.zip', 'C:\Windows\Temp\ultradefrag.zip')" <NUL
|
||||
if not exist "%UDFEXE%" (
|
||||
cmd /c ""C:\Program Files\7-Zip\7z.exe" x %UDFZIP% -o%TEMPTEMP%"
|
||||
)
|
||||
|
||||
if not exist "C:\Windows\Temp\ultradefrag-portable-6.1.0.amd64\udefrag.exe" (
|
||||
cmd /c ""C:\Program Files\7-Zip\7z.exe" x C:\Windows\Temp\ultradefrag.zip -oC:\Windows\Temp"
|
||||
if not exist "%TEMPTEMP%\SDelete.zip" (
|
||||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://download.sysinternals.com/files/SDelete.zip', '%TEMPTEMP%\SDelete.zip')" <NUL
|
||||
)
|
||||
|
||||
if not exist "C:\Windows\Temp\SDelete.zip" (
|
||||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://download.sysinternals.com/files/SDelete.zip', 'C:\Windows\Temp\SDelete.zip')" <NUL
|
||||
if not exist "%TEMPTEMP%\sdelete.exe" (
|
||||
cmd /c ""C:\Program Files\7-Zip\7z.exe" x %TEMPTEMP%\SDelete.zip -o%TEMPTEMP%"
|
||||
)
|
||||
|
||||
if not exist "C:\Windows\Temp\sdelete.exe" (
|
||||
cmd /c ""C:\Program Files\7-Zip\7z.exe" x C:\Windows\Temp\SDelete.zip -oC:\Windows\Temp"
|
||||
)
|
||||
|
||||
msiexec /qb /x C:\Windows\Temp\7z920-x64.msi
|
||||
@echo ========================================
|
||||
@echo ALL THE FILES IN MY TEMP DIRECTORY OF "%TEMPTEMP%"
|
||||
@dir %TEMPTEMP%
|
||||
@echo ========================================
|
||||
|
||||
net stop wuauserv
|
||||
rmdir /S /Q C:\Windows\SoftwareDistribution\Download
|
||||
mkdir C:\Windows\SoftwareDistribution\Download
|
||||
net start wuauserv
|
||||
|
||||
cmd /c C:\Windows\Temp\ultradefrag-portable-6.1.0.amd64\udefrag.exe --optimize --repeat C:
|
||||
cmd /c %UDFEXE% --optimize --repeat C:
|
||||
|
||||
cmd /c %SystemRoot%\System32\reg.exe ADD HKCU\Software\Sysinternals\SDelete /v EulaAccepted /t REG_DWORD /d 1 /f
|
||||
cmd /c C:\Windows\Temp\sdelete.exe -q -z C:
|
||||
cmd /c %TEMPTEMP%\sdelete.exe -q -z C:
|
||||
|
||||
rmdir /s /q %TEMPTEMP%
|
||||
|
@ -0,0 +1,7 @@
|
||||
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set OSARCHITECTURE=32BIT || set OSARCHITECTURE=64BIT
|
||||
set SZFILENAME=7z920.msi
|
||||
if %OSARCHITECTURE%==64BIT set SZFILENAME=7z920-x64.msi
|
||||
set SZURL=http://7-zip.org/a/%SZFILENAME%
|
||||
set SZDLPATH=C:\Windows\Temp\%SZFILENAME%
|
||||
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%SZURL%', '%SZDLPATH%')" <NUL
|
||||
echo msiexec /qb /i %SZDLPATH%
|
@ -0,0 +1,282 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<unattend xmlns="urn:schemas-microsoft-com:unattend">
|
||||
<servicing/>
|
||||
<settings pass="windowsPE">
|
||||
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
|
||||
<DiskConfiguration>
|
||||
<Disk wcm:action="add">
|
||||
<CreatePartitions>
|
||||
<CreatePartition wcm:action="add">
|
||||
<Order>1</Order>
|
||||
<Type>Primary</Type>
|
||||
<Extend>true</Extend>
|
||||
</CreatePartition>
|
||||
</CreatePartitions>
|
||||
<ModifyPartitions>
|
||||
<ModifyPartition wcm:action="add">
|
||||
<Extend>false</Extend>
|
||||
<Format>NTFS</Format>
|
||||
<Letter>C</Letter>
|
||||
<Order>1</Order>
|
||||
<PartitionID>1</PartitionID>
|
||||
<Label>Windows 81</Label>
|
||||
</ModifyPartition>
|
||||
</ModifyPartitions>
|
||||
<DiskID>0</DiskID>
|
||||
<WillWipeDisk>true</WillWipeDisk>
|
||||
</Disk>
|
||||
<WillShowUI>OnError</WillShowUI>
|
||||
</DiskConfiguration>
|
||||
<UserData>
|
||||
<AcceptEula>true</AcceptEula>
|
||||
<FullName>Vagrant Administrator</FullName>
|
||||
<Organization>Vagrant Inc.</Organization>
|
||||
|
||||
<!--
|
||||
NOTE: If you are re-configuring this for use of a retail key
|
||||
and using a retail ISO, you need to adjust the <ProductKey> block
|
||||
below to look like this:
|
||||
|
||||
<ProductKey>
|
||||
<Key>33PXH-7Y6KF-2VJC9-XBBR8-HVTHH</Key>
|
||||
<WillShowUI>Never</WillShowUI>
|
||||
</ProductKey>
|
||||
|
||||
Notice the addition of the `<Key>` element.
|
||||
-->
|
||||
|
||||
<!-- Product Key from http://technet.microsoft.com/en-us/library/jj612867.aspx -->
|
||||
<ProductKey>MHF9N-XY6XB-WVXMC-BTDCT-MKKG7
|
||||
<WillShowUI>Never</WillShowUI>
|
||||
</ProductKey>
|
||||
</UserData>
|
||||
<ImageInstall>
|
||||
<OSImage>
|
||||
<InstallTo>
|
||||
<DiskID>0</DiskID>
|
||||
<PartitionID>1</PartitionID>
|
||||
</InstallTo>
|
||||
<WillShowUI>OnError</WillShowUI>
|
||||
<InstallToAvailablePartition>false</InstallToAvailablePartition>
|
||||
<InstallFrom>
|
||||
<MetaData wcm:action="add">
|
||||
<Key>/IMAGE/NAME</Key>
|
||||
<Value>Windows 8.1 Enterprise Evaluation</Value>
|
||||
</MetaData>
|
||||
</InstallFrom>
|
||||
</OSImage>
|
||||
</ImageInstall>
|
||||
</component>
|
||||
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
|
||||
<SetupUILanguage>
|
||||
<UILanguage>en-US</UILanguage>
|
||||
</SetupUILanguage>
|
||||
<InputLocale>en-US</InputLocale>
|
||||
<SystemLocale>en-US</SystemLocale>
|
||||
<UILanguage>en-US</UILanguage>
|
||||
<UILanguageFallback>en-US</UILanguageFallback>
|
||||
<UserLocale>en-US</UserLocale>
|
||||
</component>
|
||||
</settings>
|
||||
<settings pass="offlineServicing">
|
||||
<component name="Microsoft-Windows-LUA-Settings" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
|
||||
<EnableLUA>false</EnableLUA>
|
||||
</component>
|
||||
</settings>
|
||||
<settings pass="oobeSystem">
|
||||
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
|
||||
<UserAccounts>
|
||||
<AdministratorPassword>
|
||||
<Value>vagrant</Value>
|
||||
<PlainText>true</PlainText>
|
||||
</AdministratorPassword>
|
||||
<LocalAccounts>
|
||||
<LocalAccount wcm:action="add">
|
||||
<Password>
|
||||
<Value>vagrant</Value>
|
||||
<PlainText>true</PlainText>
|
||||
</Password>
|
||||
<Description>Vagrant User</Description>
|
||||
<DisplayName>vagrant</DisplayName>
|
||||
<Group>administrators</Group>
|
||||
<Name>vagrant</Name>
|
||||
</LocalAccount>
|
||||
</LocalAccounts>
|
||||
</UserAccounts>
|
||||
<OOBE>
|
||||
<HideEULAPage>true</HideEULAPage>
|
||||
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
|
||||
<NetworkLocation>Home</NetworkLocation>
|
||||
<ProtectYourPC>1</ProtectYourPC>
|
||||
</OOBE>
|
||||
<AutoLogon>
|
||||
<Password>
|
||||
<Value>vagrant</Value>
|
||||
<PlainText>true</PlainText>
|
||||
</Password>
|
||||
<Username>vagrant</Username>
|
||||
<Enabled>true</Enabled>
|
||||
</AutoLogon>
|
||||
<FirstLogonCommands>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</CommandLine>
|
||||
<Description>Set Execution Policy</Description>
|
||||
<Order>1</Order>
|
||||
<RequiresUserInput>true</RequiresUserInput>
|
||||
</SynchronousCommand>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>cmd.exe /c winrm quickconfig -q</CommandLine>
|
||||
<Description>winrm quickconfig -q</Description>
|
||||
<Order>3</Order>
|
||||
<RequiresUserInput>true</RequiresUserInput>
|
||||
</SynchronousCommand>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>cmd.exe /c winrm quickconfig -transport:http</CommandLine>
|
||||
<Description>winrm quickconfig -transport:http</Description>
|
||||
<Order>4</Order>
|
||||
<RequiresUserInput>true</RequiresUserInput>
|
||||
</SynchronousCommand>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>cmd.exe /c winrm set winrm/config @{MaxTimeoutms="1800000"}</CommandLine>
|
||||
<Description>Win RM MaxTimoutms</Description>
|
||||
<Order>5</Order>
|
||||
<RequiresUserInput>true</RequiresUserInput>
|
||||
</SynchronousCommand>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>cmd.exe /c winrm set winrm/config/winrs @{MaxMemoryPerShellMB="800"}</CommandLine>
|
||||
<Description>Win RM MaxMemoryPerShellMB</Description>
|
||||
<Order>6</Order>
|
||||
<RequiresUserInput>true</RequiresUserInput>
|
||||
</SynchronousCommand>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>cmd.exe /c winrm set winrm/config/service @{AllowUnencrypted="true"}</CommandLine>
|
||||
<Description>Win RM AllowUnencrypted</Description>
|
||||
<Order>7</Order>
|
||||
<RequiresUserInput>true</RequiresUserInput>
|
||||
</SynchronousCommand>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>cmd.exe /c winrm set winrm/config/service/auth @{Basic="true"}</CommandLine>
|
||||
<Description>Win RM auth Basic</Description>
|
||||
<Order>8</Order>
|
||||
<RequiresUserInput>true</RequiresUserInput>
|
||||
</SynchronousCommand>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>cmd.exe /c winrm set winrm/config/client/auth @{Basic="true"}</CommandLine>
|
||||
<Description>Win RM client auth Basic</Description>
|
||||
<Order>9</Order>
|
||||
<RequiresUserInput>true</RequiresUserInput>
|
||||
</SynchronousCommand>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>cmd.exe /c winrm set winrm/config/listener?Address=*+Transport=HTTP @{Port="5985"} </CommandLine>
|
||||
<Description>Win RM listener Address/Port</Description>
|
||||
<Order>10</Order>
|
||||
<RequiresUserInput>true</RequiresUserInput>
|
||||
</SynchronousCommand>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes </CommandLine>
|
||||
<Description>Win RM adv firewall enable</Description>
|
||||
<Order>11</Order>
|
||||
<RequiresUserInput>true</RequiresUserInput>
|
||||
</SynchronousCommand>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>cmd.exe /c netsh firewall add portopening TCP 5985 "Port 5985" </CommandLine>
|
||||
<Description>Win RM port open</Description>
|
||||
<Order>12</Order>
|
||||
<RequiresUserInput>true</RequiresUserInput>
|
||||
</SynchronousCommand>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>cmd.exe /c net stop winrm </CommandLine>
|
||||
<Description>Stop Win RM Service </Description>
|
||||
<Order>13</Order>
|
||||
<RequiresUserInput>true</RequiresUserInput>
|
||||
</SynchronousCommand>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>cmd.exe /c sc config winrm start= auto</CommandLine>
|
||||
<Description>Win RM Autostart</Description>
|
||||
<Order>14</Order>
|
||||
<RequiresUserInput>true</RequiresUserInput>
|
||||
</SynchronousCommand>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>cmd.exe /c net start winrm</CommandLine>
|
||||
<Description>Start Win RM Service</Description>
|
||||
<Order>15</Order>
|
||||
<RequiresUserInput>true</RequiresUserInput>
|
||||
</SynchronousCommand>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v HideFileExt /t REG_DWORD /d 0 /f</CommandLine>
|
||||
<Order>16</Order>
|
||||
<Description>Show file extensions in Explorer</Description>
|
||||
</SynchronousCommand>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\Console /v QuickEdit /t REG_DWORD /d 1 /f</CommandLine>
|
||||
<Order>17</Order>
|
||||
<Description>Enable QuickEdit mode</Description>
|
||||
</SynchronousCommand>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v Start_ShowRun /t REG_DWORD /d 1 /f</CommandLine>
|
||||
<Order>18</Order>
|
||||
<Description>Show Run command in Start Menu</Description>
|
||||
</SynchronousCommand>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>%SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v StartMenuAdminTools /t REG_DWORD /d 1 /f</CommandLine>
|
||||
<Order>19</Order>
|
||||
<Description>Show Administrative Tools in Start Menu</Description>
|
||||
</SynchronousCommand>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>%SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateFileSizePercent /t REG_DWORD /d 0 /f</CommandLine>
|
||||
<Order>20</Order>
|
||||
<Description>Zero Hibernation File</Description>
|
||||
</SynchronousCommand>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>%SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Power\ /v HibernateEnabled /t REG_DWORD /d 0 /f</CommandLine>
|
||||
<Order>21</Order>
|
||||
<Description>Disable Hibernation Mode</Description>
|
||||
</SynchronousCommand>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>cmd.exe /c wmic useraccount where "name='vagrant'" set PasswordExpires=FALSE</CommandLine>
|
||||
<Order>22</Order>
|
||||
<Description>Disable password expiration for vagrant user</Description>
|
||||
</SynchronousCommand>
|
||||
<!-- WITHOUT WINDOWS UPDATES -->
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\openssh.ps1 -AutoStart</CommandLine>
|
||||
<Description>Install OpenSSH</Description>
|
||||
<Order>99</Order>
|
||||
<RequiresUserInput>true</RequiresUserInput>
|
||||
</SynchronousCommand>
|
||||
<!-- END WITHOUT WINDOWS UPDATES -->
|
||||
<!-- WITH WINDOWS UPDATES -->
|
||||
<!--
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>cmd.exe /c a:\microsoft-updates.bat</CommandLine>
|
||||
<Order>98</Order>
|
||||
<Description>Enable Microsoft Updates</Description>
|
||||
</SynchronousCommand>
|
||||
<SynchronousCommand wcm:action="add">
|
||||
<CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\win-updates.ps1</CommandLine>
|
||||
<Description>Install Windows Updates</Description>
|
||||
<Order>100</Order>
|
||||
<RequiresUserInput>true</RequiresUserInput>
|
||||
</SynchronousCommand>
|
||||
-->
|
||||
<!-- END WITH WINDOWS UPDATES -->
|
||||
</FirstLogonCommands>
|
||||
<ShowWindowsLive>false</ShowWindowsLive>
|
||||
</component>
|
||||
</settings>
|
||||
<settings pass="specialize">
|
||||
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
|
||||
<OEMInformation>
|
||||
<HelpCustomized>false</HelpCustomized>
|
||||
</OEMInformation>
|
||||
<!-- Rename computer here. -->
|
||||
<ComputerName>vagrant-81-x86</ComputerName>
|
||||
<TimeZone>Central Standard Time</TimeZone>
|
||||
<RegisteredOwner/>
|
||||
</component>
|
||||
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
|
||||
<SkipAutoActivation>true</SkipAutoActivation>
|
||||
</component>
|
||||
</settings>
|
||||
<cpi:offlineImage xmlns:cpi="urn:schemas-microsoft-com:cpi" cpi:source="catalog:d:/sources/install_windows 7 ENTERPRISE.clg"/>
|
||||
</unattend>
|
@ -0,0 +1,8 @@
|
||||
- what the FUCK is going on in vagrant-ssh.bat
|
||||
- better windows update mechanism imo
|
||||
- would like to use the -tag in the name for the vagrant box too, but that requires parameterizing both the packerfile and the vagrantfile template :/ not sure what to do about this
|
||||
- store passwords securely for shit and/or generate them on the fly
|
||||
- test `lab2 -action VagrantUp -baseConfigName windows_81_x86 -tag PreLunchTest` tomorrow afternoon - will it have 89 days remaining? or 90? basically, was it activated at boot or nah?
|
||||
- need to audit **all** of the scripts ../scripts actually
|
||||
- it seems like the vbox tools aren't getting installed? why not?
|
||||
- enable clipboard and drag&drop in my Vagrantfile - though NOT for throwaway VMs that might be insecure!
|
@ -0,0 +1,32 @@
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
Vagrant.require_version ">= 1.6.2"
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.define "vagrant-windows-81-x86"
|
||||
config.vm.box = "wintriallab-windows_81_x86"
|
||||
config.vm.communicator = "winrm"
|
||||
|
||||
# Admin user name and password
|
||||
config.winrm.username = "vagrant"
|
||||
config.winrm.password = "vagrant"
|
||||
|
||||
config.vm.guest = :windows
|
||||
config.windows.halt_timeout = 15
|
||||
|
||||
config.vm.network :forwarded_port, guest: 3389, host: 3389, id: "rdp", auto_correct: true
|
||||
config.vm.network :forwarded_port, guest: 22, host: 2222, id: "ssh", auto_correct: true
|
||||
|
||||
config.vm.provider :virtualbox do |v, override|
|
||||
v.gui = true
|
||||
v.customize ["modifyvm", :id, "--memory", 2048]
|
||||
v.customize ["modifyvm", :id, "--cpus", 2]
|
||||
v.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ]
|
||||
v.customize ["storageattach", :id, "--storagectl", "IDE Controller", "--port", 1, "--device", 0, "--type", "dvddrive", "--medium", "emptydrive"]
|
||||
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
|
||||
end
|
Loading…
Reference in new issue