Skip to content

Commit

Permalink
Improved domain admin check
Browse files Browse the repository at this point in the history
Uses the built-in `Admin$` server share that is active with all domain servers
  • Loading branch information
Andrew-J-Larson committed Jan 28, 2025
1 parent 4a7c62e commit a500430
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
8 changes: 3 additions & 5 deletions Windows/Prepare-PC/Prepare-PC.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<#
.SYNOPSIS
Prepare PC v1.3.3
Prepare PC v1.3.4
.DESCRIPTION
Script will prepare a fresh machine all the way up to a domain joining.
Expand Down Expand Up @@ -283,9 +283,7 @@ $currentUser = ($currentUsername).split('\')[-1]
$shortDomainName = Get-Content "${resources}\shortDomainName.txt"
$domainName = Get-Content "${resources}\domainName.txt"
$adRootOU = "DC=$(${domainName}.Replace(".",",DC="))"
$mainDomainServerName = Get-Content "${resources}\mainDomainServerName.txt"
$mainDomainServerShareName = Get-Content "${resources}\mainDomainServerShareName.txt"
$mainDomainServerShare = "\\${mainDomainServerName}.${domainName}\${mainDomainServerShareName}"
$domainAdminServerShare = "\\${domainName}\" + 'Admin$'
$localAdminUser = Get-Content "${resources}\localAdminUser.txt"
$localAdminPass = Get-Content "${resources}\localAdminPass.txt"
$adPathFromRootOU = Get-Content "${resources}\adPathFromRootOU.txt"
Expand Down Expand Up @@ -897,7 +895,7 @@ do {
$tempUserName = $shortDomainName + '\' + $tempUserName
}
$credentials = New-Object System.Management.Automation.PSCredential($tempUserName, $tempPassword)
$validDomainAdminUser = New-PSDrive -Name $tempDriveLetter -PSProvider FileSystem -Root $mainDomainServerShare -Credential $credentials -ErrorAction SilentlyContinue
$validDomainAdminUser = New-PSDrive -Name $tempDriveLetter -PSProvider FileSystem -Root $domainAdminServerShare -Credential $credentials -ErrorAction SilentlyContinue
Remove-PSDrive -Name $tempDriveLetter -ErrorAction SilentlyContinue
} while (-Not $validDomainAdminUser)
Write-Output "Domain admin user credentials confirmed."
Expand Down
1 change: 0 additions & 1 deletion Windows/Prepare-PC/resources/mainDomainServerName.txt

This file was deleted.

1 change: 0 additions & 1 deletion Windows/Prepare-PC/resources/mainDomainServerShareName.txt

This file was deleted.

0 comments on commit a500430

Please sign in to comment.