Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Bob Tanner
packer-windows
Commits
208f69ff
Commit
208f69ff
authored
Nov 07, 2016
by
Stefan Scherer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try domain controller
parent
5776191e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
204 additions
and
0 deletions
+204
-0
scripts/create-domain.ps1
scripts/create-domain.ps1
+39
-0
windows_2016_dc.json
windows_2016_dc.json
+165
-0
No files found.
scripts/create-domain.ps1
0 → 100644
View file @
208f69ff
if
((
gwmi
win32_computersystem
)
.
partofdomain
-eq
$false
)
{
Write-Host
'Creating domain controller'
# Disable password complexity policy
secedit
/export
/cfg
C:\secpol.cfg
(
gc
C:\secpol.cfg
)
.
replace
(
"PasswordComplexity = 1"
,
"PasswordComplexity = 0"
)
|
Out-File
C:\secpol.cfg
secedit
/configure
/db
C:\Windows\security\local.sdb
/cfg
C:\secpol.cfg
/areas
SECURITYPOLICY
rm
-force
C:\secpol.cfg
-confirm
:
$false
# Set administrator password
$computerName
=
$
env
:
COMPUTERNAME
$adminPassword
=
"vagrant"
$adminUser
=
[
ADSI
]
"WinNT://
$computerName
/Administrator,User"
$adminUser
.
SetPassword
(
$adminPassword
)
$PlainPassword
=
"vagrant"
# "P@ssw0rd"
$SecurePassword
=
$PlainPassword
|
ConvertTo-SecureString
-AsPlainText
-Force
# Windows Server 2012 R2
Install-WindowsFeature
AD-domain-services
Import-Module
ADDSDeployment
Install-ADDSForest
`
-SafeModeAdministratorPassword
$SecurePassword
`
-CreateDnsDelegation
:
$false
`
-DatabasePath
"C:\Windows\NTDS"
`
-DomainMode
"Win2012"
`
-DomainName
"windomain.local"
`
-DomainNetbiosName
"WINDOMAIN"
`
-ForestMode
"Win2012"
`
-InstallDns
:
$true
`
-LogPath
"C:\Windows\NTDS"
`
-NoRebootOnCompletion
:
$true
`
-SysvolPath
"C:\Windows\SYSVOL"
`
-Force
:
$true
$newDNSServers
=
"8.8.8.8"
,
"4.4.4.4"
$adapters
=
Get-WmiObject
Win32_NetworkAdapterConfiguration
|
Where-Object
{
$_
.
IPAddress
-eq
"10.0.2.15"
}
$adapters
|
ForEach-Object
{
$_
.
SetDNSServerSearchOrder
(
$newDNSServers
)}
}
windows_2016_dc.json
0 → 100644
View file @
208f69ff
{
"builders"
:
[
{
"vm_name"
:
"windows_2016_dc"
,
"type"
:
"hyperv-iso"
,
"disk_size"
:
41440
,
"boot_wait"
:
"0s"
,
"headless"
:
false
,
"guest_additions_mode"
:
"disable"
,
"iso_url"
:
"{{user `iso_url`}}"
,
"iso_checksum_type"
:
"{{user `iso_checksum_type`}}"
,
"iso_checksum"
:
"{{user `iso_checksum`}}"
,
"floppy_files"
:
[
"{{user `autounattend`}}"
,
"./scripts/disable-screensaver.ps1"
,
"./scripts/disable-winrm.ps1"
,
"./scripts/enable-winrm.ps1"
,
"./scripts/microsoft-updates.bat"
,
"./scripts/win-updates.ps1"
],
"communicator"
:
"winrm"
,
"winrm_username"
:
"vagrant"
,
"winrm_password"
:
"vagrant"
,
"winrm_timeout"
:
"4h"
,
"shutdown_command"
:
"shutdown /s /t 10 /f /d p:4:1 /c
\"
Packer Shutdown
\"
"
,
"ram_size_mb"
:
2048
,
"cpu"
:
2
,
"switch_name"
:
"{{user `hyperv_switchname`}}"
,
"enable_secure_boot"
:
true
},
{
"vm_name"
:
"windows_2016_dc"
,
"type"
:
"vmware-iso"
,
"communicator"
:
"winrm"
,
"iso_url"
:
"{{user `iso_url`}}"
,
"iso_checksum_type"
:
"{{user `iso_checksum_type`}}"
,
"iso_checksum"
:
"{{user `iso_checksum`}}"
,
"headless"
:
false
,
"boot_wait"
:
"2m"
,
"winrm_username"
:
"vagrant"
,
"winrm_password"
:
"vagrant"
,
"winrm_timeout"
:
"6h"
,
"shutdown_command"
:
"shutdown /s /t 10 /f /d p:4:1 /c
\"
Packer Shutdown
\"
"
,
"guest_os_type"
:
"windows8srv-64"
,
"disk_size"
:
61440
,
"vnc_port_min"
:
5900
,
"vnc_port_max"
:
5980
,
"floppy_files"
:
[
"{{user `autounattend`}}"
,
"./scripts/disable-screensaver.ps1"
,
"./scripts/disable-winrm.ps1"
,
"./scripts/enable-winrm.ps1"
,
"./scripts/microsoft-updates.bat"
,
"./scripts/win-updates.ps1"
],
"vmx_data"
:
{
"RemoteDisplay.vnc.enabled"
:
"false"
,
"RemoteDisplay.vnc.port"
:
"5900"
,
"memsize"
:
"2048"
,
"numvcpus"
:
"2"
,
"scsi0.virtualDev"
:
"lsisas1068"
}
},
{
"vm_name"
:
"windows_2016_dc"
,
"type"
:
"virtualbox-iso"
,
"communicator"
:
"winrm"
,
"iso_url"
:
"{{user `iso_url`}}"
,
"iso_checksum_type"
:
"{{user `iso_checksum_type`}}"
,
"iso_checksum"
:
"{{user `iso_checksum`}}"
,
"headless"
:
false
,
"boot_wait"
:
"2m"
,
"winrm_username"
:
"vagrant"
,
"winrm_password"
:
"vagrant"
,
"winrm_timeout"
:
"6h"
,
"shutdown_command"
:
"shutdown /s /t 10 /f /d p:4:1 /c
\"
Packer Shutdown
\"
"
,
"guest_os_type"
:
"Windows2012_64"
,
"guest_additions_mode"
:
"disable"
,
"disk_size"
:
61440
,
"floppy_files"
:
[
"{{user `autounattend`}}"
,
"./scripts/disable-screensaver.ps1"
,
"./scripts/disable-winrm.ps1"
,
"./scripts/enable-winrm.ps1"
,
"./scripts/microsoft-updates.bat"
,
"./scripts/win-updates.ps1"
,
"./scripts/oracle-cert.cer"
],
"vboxmanage"
:
[
[
"modifyvm"
,
"{{.Name}}"
,
"--memory"
,
"2048"
],
[
"modifyvm"
,
"{{.Name}}"
,
"--cpus"
,
"2"
]
]
}
],
"provisioners"
:
[
{
"type"
:
"windows-shell"
,
"scripts"
:
[
"./scripts/vm-guest-tools.bat"
,
"./scripts/enable-rdp.bat"
]
},
{
"type"
:
"powershell"
,
"scripts"
:
[
"./scripts/debloat-windows.ps1"
]
},
{
"type"
:
"powershell"
,
"inline"
:
[
"Install-WindowsFeature AD-Domain-Services"
,
"Import-Module ADDSDeployment"
,
"Install-ADDSForest `"
,
" -DomainName {{user `DomainName`}} `"
,
" -DomainNetbiosName {{user `DomainNetbiosName`}} `"
,
" -CreateDnsDelegation:$false -DatabasePath
\"
C:
\\
Windows
\\
NTDS
\"
`"
,
" -DomainMode
\"
Win2012R2
\"
-ForestMode
\"
Win2012R2
\"
`"
,
" -InstallDns:$true -LogPath
\"
C:
\\
Windows
\\
NTDS
\"
`"
,
" -NoRebootOnCompletion:$true -SysvolPath
\"
C:
\\
Windows
\\
SYSVOL
\"
`"
,
" -SafeModeAdministratorPassword (ConvertTo-SecureString `"
,
" -String
\"
{{user `SafeModeAdministratorPassword`}}
\"
`"
,
" -AsPlainText -Force) -Force:$true"
]
},
{
"type"
:
"windows-restart"
},
{
"type"
:
"windows-shell"
,
"scripts"
:
[
"./scripts/compile-dotnet-assemblies.bat"
,
"./scripts/uac-enable.bat"
,
"./scripts/compact.bat"
]
}
],
"post-processors"
:
[
{
"type"
:
"vagrant"
,
"keep_input_artifact"
:
false
,
"output"
:
"windows_2016_dc_{{.Provider}}.box"
,
"vagrantfile_template"
:
"vagrantfile-windows_2016.template"
}
],
"variables"
:
{
"iso_url"
:
"http://care.dlservice.microsoft.com/dl/download/1/6/F/16FA20E6-4662-482A-920B-1A45CF5AAE3C/14393.0.160715-1616.RS1_RELEASE_SERVER_EVAL_X64FRE_EN-US.ISO"
,
"iso_checksum_type"
:
"md5"
,
"iso_checksum"
:
"18a4f00a675b0338f3c7c93c4f131beb"
,
"autounattend"
:
"./answer_files/2016_core/Autounattend.xml"
,
"DomainName"
:
"windomain.local"
,
"DomainNetbiosName"
:
"windom"
,
"SafeModeAdministratorPassword"
:
"BadAdminPassword!"
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment