From f1e0a20c008605b2c2e6178c90ef0750a79b5131 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Fri, 3 Jan 2020 19:17:30 -0500 Subject: [PATCH] Add LocalAdmin Account and do computer rename and domain join in script --- Set-ComputerName.ps1 | 15 ++++++++-- autounattend.xml | 66 ++++++++++++++++++++++---------------------- 2 files changed, 45 insertions(+), 36 deletions(-) diff --git a/Set-ComputerName.ps1 b/Set-ComputerName.ps1 index 9027e03..2619de9 100755 --- a/Set-ComputerName.ps1 +++ b/Set-ComputerName.ps1 @@ -11,7 +11,7 @@ $ComputerList = Import-Csv -Path "$scriptPath\$FileName" # look up computer name by MAC address ForEach ($Computer in $ComputerList) { - Write-Host "$($Computer.CN) $($Computer.MAC) $thisComputerMac" + Write-Host "$($Computer.CN) $($Computer.MAC) $thisComputerMac" If ($thisComputerMAC -match $Computer.MAC) { Write-Host "$($Computer.CN) matches the localhost MAC Address: $thisComputerMAC" $NewComputerName = $Computer.CN @@ -24,6 +24,15 @@ If ($Null -eq $NewComputerName) { $NewComputerName = Read-Host -Prompt "Please enter desired computer name then hit enter" } -# rename computer +$cred = New-Object System.Management.Automation.PsCredential("SAWTOOTH\Administrator", (ConvertTo-SecureString "REPLACE_WITH_PASSWORD" -AsPlainText -Force)) + +# rename computer and join to domain Write-Host "Computer will be renamed to $NewComputerName." -Rename-Computer -NewName $NewComputerName -Force -Verbose \ No newline at end of file +Rename-Computer -NewName $NewComputerName -Force -Verbose +Add-Computer -Force -DomainName sawtooth.claremontmakerspace.org -Options JoinWithNewName -Credential $cred +#Start-Sleep -Seconds 5 +#Restart-Computer + +# Install Salt +# Write-Host "Installing Salt with minion name: $NewComputerName." +# \\ucs\Software\Salt-Minion-2019.2.2-Py3-AMD64-Setup.exe /S /minion-name="$NewComputerName" diff --git a/autounattend.xml b/autounattend.xml index 8adb725..24ff5c5 100755 --- a/autounattend.xml +++ b/autounattend.xml @@ -124,30 +124,6 @@ * W269N-WFGWX-YVC9B-4J6C9-T83GX - - - - sawtooth.claremontmakerspace.org - REPLACE_WITH_PASSWORD - administrator - - sawtooth.claremontmakerspace.org - - - - - - - - sawtooth.claremontmakerspace.org - REPLACE_WITH_PASSWORD - administrator - - 1 - powershell -File \\ucs.sawtooth.claremontmakerspace.org\Software\unattend\Set-ComputerName.ps1 - - - @@ -161,20 +137,44 @@ 1 - - - - Administrators - Administrator - - sawtooth.clarmontmakerspace.org - - + + + + REPLACE_WITH_LOCAL_ADMIN_PASSWORD + true</PlainText> + </Password> + <Description>Local Administrator</Description> + <DisplayName>Local Administrator</DisplayName> + <Group>Administrators;Power Users</Group> + <Name>LocalAdmin</Name> + </LocalAccount> + </LocalAccounts> </UserAccounts> <RegisteredOrganization></RegisteredOrganization> <RegisteredOwner></RegisteredOwner> <DisableAutoDaylightTimeSet>false</DisableAutoDaylightTimeSet> <TimeZone>Eastern Standard Time</TimeZone> + <AutoLogon> + <Enabled>true</Enabled> + <LogonCount>2</LogonCount> + <Username>LocalAdmin</Username> + <Password> + <Value>REPLACE_WITH_LOCAL_ADMIN_PASSWORD</Value> + </Password> + </AutoLogon> + <FirstLogonCommands> + <SynchronousCommand wcm:action="add"> + <CommandLine>net use \\ucs.sawtooth.claremontmakerspace.org\software /user:SAWTOOTH\Administrator REPLACE_WITH_PASSWORD</CommandLine> + <Description>Set Up UCS Share</Description> + <Order>1</Order> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>powershell -NoExit -executionPolicy Bypass -File \\ucs.sawtooth.claremontmakerspace.org\Software\unattend\Set-ComputerName.ps1</CommandLine> + <Description>Set Computer Name</Description> + <Order>2</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + </FirstLogonCommands> </component> </settings> <cpi:offlineImage cpi:source="wim:d:/sources/install.wim#Windows 10 Pro" xmlns:cpi="urn:schemas-microsoft-com:cpi" />