Add LocalAdmin Account and do computer rename and domain join in script

This commit is contained in:
Adam Goldsmith 2020-01-03 19:17:30 -05:00
parent d7d05d8f2f
commit f1e0a20c00
2 changed files with 45 additions and 36 deletions

View File

@ -11,7 +11,7 @@ $ComputerList = Import-Csv -Path "$scriptPath\$FileName"
# look up computer name by MAC address # look up computer name by MAC address
ForEach ($Computer in $ComputerList) { ForEach ($Computer in $ComputerList) {
Write-Host "$($Computer.CN) $($Computer.MAC) $thisComputerMac" Write-Host "$($Computer.CN) $($Computer.MAC) $thisComputerMac"
If ($thisComputerMAC -match $Computer.MAC) { If ($thisComputerMAC -match $Computer.MAC) {
Write-Host "$($Computer.CN) matches the localhost MAC Address: $thisComputerMAC" Write-Host "$($Computer.CN) matches the localhost MAC Address: $thisComputerMAC"
$NewComputerName = $Computer.CN $NewComputerName = $Computer.CN
@ -24,6 +24,15 @@ If ($Null -eq $NewComputerName) {
$NewComputerName = Read-Host -Prompt "Please enter desired computer name then hit enter" $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." Write-Host "Computer will be renamed to $NewComputerName."
Rename-Computer -NewName $NewComputerName -Force -Verbose 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"

View File

@ -124,30 +124,6 @@
<ComputerName>*</ComputerName> <ComputerName>*</ComputerName>
<ProductKey>W269N-WFGWX-YVC9B-4J6C9-T83GX</ProductKey> <ProductKey>W269N-WFGWX-YVC9B-4J6C9-T83GX</ProductKey>
</component> </component>
<component name="Microsoft-Windows-UnattendedJoin" 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">
<Identification>
<Credentials>
<Domain>sawtooth.claremontmakerspace.org</Domain>
<Password>REPLACE_WITH_PASSWORD</Password>
<Username>administrator</Username>
</Credentials>
<JoinDomain>sawtooth.claremontmakerspace.org</JoinDomain>
<JoinWorkgroup></JoinWorkgroup>
</Identification>
</component>
<component name="Microsoft-Windows-Deployment" 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">
<RunSynchronous>
<RunSynchronousCommand wcm:action="add">
<Credentials>
<Domain>sawtooth.claremontmakerspace.org</Domain>
<Password>REPLACE_WITH_PASSWORD</Password>
<Username>administrator</Username>
</Credentials>
<Order>1</Order>
<Path>powershell -File \\ucs.sawtooth.claremontmakerspace.org\Software\unattend\Set-ComputerName.ps1</Path>
</RunSynchronousCommand>
</RunSynchronous>
</component>
</settings> </settings>
<settings pass="oobeSystem"> <settings pass="oobeSystem">
<component name="Microsoft-Windows-Shell-Setup" 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"> <component name="Microsoft-Windows-Shell-Setup" 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">
@ -161,20 +137,44 @@
<ProtectYourPC>1</ProtectYourPC> <ProtectYourPC>1</ProtectYourPC>
</OOBE> </OOBE>
<UserAccounts> <UserAccounts>
<DomainAccounts> <LocalAccounts>
<DomainAccountList wcm:action="add"> <LocalAccount wcm:action="add">
<DomainAccount wcm:action="add"> <Password>
<Group>Administrators</Group> <Value>REPLACE_WITH_LOCAL_ADMIN_PASSWORD</Value>
<Name>Administrator</Name> <PlainText>true</PlainText>
</DomainAccount> </Password>
<Domain>sawtooth.clarmontmakerspace.org</Domain> <Description>Local Administrator</Description>
</DomainAccountList> <DisplayName>Local Administrator</DisplayName>
</DomainAccounts> <Group>Administrators;Power Users</Group>
<Name>LocalAdmin</Name>
</LocalAccount>
</LocalAccounts>
</UserAccounts> </UserAccounts>
<RegisteredOrganization></RegisteredOrganization> <RegisteredOrganization></RegisteredOrganization>
<RegisteredOwner></RegisteredOwner> <RegisteredOwner></RegisteredOwner>
<DisableAutoDaylightTimeSet>false</DisableAutoDaylightTimeSet> <DisableAutoDaylightTimeSet>false</DisableAutoDaylightTimeSet>
<TimeZone>Eastern Standard Time</TimeZone> <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> </component>
</settings> </settings>
<cpi:offlineImage cpi:source="wim:d:/sources/install.wim#Windows 10 Pro" xmlns:cpi="urn:schemas-microsoft-com:cpi" /> <cpi:offlineImage cpi:source="wim:d:/sources/install.wim#Windows 10 Pro" xmlns:cpi="urn:schemas-microsoft-com:cpi" />