Skip to content

Instantly share code, notes, and snippets.

@tvories
tvories / 2019-base.json
Created May 19, 2019 15:17
Base OS Deployment for Server 2019 (No updates)
{
"variables": {
"name": "2019",
"guest_os_type": "windows9srv-64",
"iso_checksum": "7B463563206DCE275F2D3FF77AC36C430052FAE161CD4F8B31F3DC7AF1C3F418",
"iso_url": "file://C\\Users\\taylor\\Downloads\\en_windows_server_2019_x64_dvd_3c2cf1202.iso",
"iso_checksum_type": "sha256",
"answerfile": "answer_files/2019/Autounattend.xml",
"disk_size": "40960"
},
@tvories
tvories / autounattend.xml
Created May 19, 2019 15:16
Packer Autounattend for Server 2019
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="windowsPE">
<component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SetupUILanguage>
<UILanguage>en-US</UILanguage>
</SetupUILanguage>
<InputLocale>en-US</InputLocale>
<SystemLocale>en-US</SystemLocale>
{
"variables": {
"name": "packer-ubuntu-1804",
"build_cpu_cores": "2",
"build_memory": "1024",
"cpu_cores": "1",
"memory": "512",
"disk_size": "20480",
"headless": "false",
"vm_hardware_version": "10",
@tvories
tvories / Get-ActivationStatus.ps1
Created January 16, 2018 16:59
Get-ActivationStatus - Gets activation status for Windows machine.
function Get-ActivationStatus {
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[string]$ComputerName = $Env:COMPUTERNAME,
[System.Management.Automation.CredentialAttribute()]$Credential
)
process {
try {
# Load CimInstance in Server2003 Compatability Mode
@tvories
tvories / Get-LocalAdmins.ps1
Created January 16, 2018 16:55
Get-LocalAdministrators
function Get-LocalAdministrators {
param ([string]$computername=$env:computername,
[System.Management.Automation.CredentialAttribute()]$Credential
)
$computername = $computername.toupper()
$ADMINS = get-wmiobject -computername $computername -Credential $Credential -query "select * from win32_groupuser where GroupComponent=""Win32_Group.Domain='$computername',Name='administrators'""" | % {$_.partcomponent}
foreach ($ADMIN in $ADMINS) {
$admin = $admin.replace("\\$computername\root\cimv2:Win32_UserAccount.Domain=","") # trims the results for a user