minor rearranging

This commit is contained in:
2025-10-03 22:45:57 -05:00
parent 4af8ff2fa2
commit 080034b176
5 changed files with 85 additions and 73 deletions

View File

@@ -9,11 +9,11 @@ $CompName = $env:COMPUTERNAME
$ADCompOU = ([adsisearcher]"(&(objectClass=computer)(sAMAccountName=$CompName$))").FindOne().GetDirectoryEntry().distinguishedName $ADCompOU = ([adsisearcher]"(&(objectClass=computer)(sAMAccountName=$CompName$))").FindOne().GetDirectoryEntry().distinguishedName
$PCNamePrefix = ($CompName.Substring(0,$CompName.IndexOf("-"))) $PCNamePrefix = ($CompName.Substring(0,$CompName.IndexOf("-")))
$PCNameSuffix = ($CompName.Substring($CompName.IndexOf("-")+1)) $PCNameSuffix = ($CompName.Substring($CompName.IndexOf("-")+1))
# Domain Credentials to be used
. "\\berrypunch.technolog.net\PSCredentials$\Credentials-WKSDeploy.ps1"
Function RenamePCTNGPrefix { Function RenamePCTNGPrefix {
Write-Host "Renaming this computer to TNG-$PCNameSuffix." Write-Host "Renaming this computer to TNG-$PCNameSuffix."
# Domain Credentials to be used
. "\\berrypunch.technolog.net\PSCredentials$\Credentials-WKSDeploy.ps1"
Rename-Computer -NewName "TNG-$PCNameSuffix" -DomainCredential $DomainCredential -Restart Rename-Computer -NewName "TNG-$PCNameSuffix" -DomainCredential $DomainCredential -Restart
} }

View File

@@ -4,7 +4,7 @@
Start-Transcript -Path "c:\irnh\Install-MSOffice.log" -Append Start-Transcript -Path "c:\irnh\Install-MSOffice.log" -Append
$SoftwareDeployLocation = "\\minuette2.technolog.net\SoftwareLibrary\Software\MSOffice" $SoftwareDeployLocation = "\\minuette2.technolog.net\Software\Software\MSOffice"
$ParamVersion = $args[0] $ParamVersion = $args[0]
# Office Install Checks # Office Install Checks
@@ -18,7 +18,7 @@ $Office2024 = (Get-WmiObject -Class Win32_Product | where name -like "Microsoft
Function CheckInstall { Function CheckInstall {
if ($null -ne $OfficeVersionInstalled) { if ($null -ne $OfficeVersionInstalled) {
if ($OfficeVersionInstalled -ge "16.0" ) { # Checks if currently installed Office is less than version 16 (2016) if ($OfficeVersionInstalled -ge "16.0" ) { # Checks if currently installed Office is less than version 16 (2016)
if ($null -eq $Office2016 -and $ParamVersion -eq 2016) { if ($null -ne $Office2016 -and $ParamVersion -eq 2016) {
Write-Host "Office $ParamVersion is already installed. No action will be taken." Write-Host "Office $ParamVersion is already installed. No action will be taken."
return $true return $true
} elseif ($null -ne $Office2019 -and $ParamVersion -eq 2019) { } elseif ($null -ne $Office2019 -and $ParamVersion -eq 2019) {

View File

@@ -15,7 +15,7 @@ $ZabbixServer = "10.10.0.90"
$ZabbixAgentLogFile = "$InstallFolder\zabbix_agentd.log" $ZabbixAgentLogFile = "$InstallFolder\zabbix_agentd.log"
Function CheckZabbixInstall { Function CheckZabbixInstall {
if ($ZabbixVersionInstalled -ne $null) { if ($null -ne $ZabbixVersionInstalled) {
if ($ZabbixVersionInstalled -like "$SDZabbixVersion*") { if ($ZabbixVersionInstalled -like "$SDZabbixVersion*") {
return $true return $true
} else { } else {

View File

@@ -30,6 +30,10 @@ if ($CompType -like "WKS") {
Write-Host "Detected computer name as TEST - domain joining to Testing WKS OU" Write-Host "Detected computer name as TEST - domain joining to Testing WKS OU"
$DomainOU = "OU=TestingWKS,OU=Workstations,DC=technolog,DC=net" $DomainOU = "OU=TestingWKS,OU=Workstations,DC=technolog,DC=net"
} }
elseif ($PCNamePrefix -like "HEADEND") {
Write-Host "Detected computer name as HEADEND - domain joining to Headend WKS OU"
$DomainOU = "OU=Headend,OU=Workstations,DC=technolog,DC=net"
}
else { else {
Write-Host "Computer name is unusual - domain joining to Standard WKS OU" Write-Host "Computer name is unusual - domain joining to Standard WKS OU"
$DomainOU = "OU=Workstations,DC=technolog,DC=net" $DomainOU = "OU=Workstations,DC=technolog,DC=net"
@@ -46,7 +50,7 @@ if ($CompType -like "WKS") {
. "$MDTPath\_Scripts\Credentials-MDTJoinDomain.ps1" . "$MDTPath\_Scripts\Credentials-MDTJoinDomain.ps1"
Write-Host "Domain joining to Utility OU" Write-Host "Domain joining to Utility OU"
$DomainOU = "OU=Utility,DC=technolog,DC=net" $DomainOU = "OU=Utility,OU=Workstations,DC=technolog,DC=net"
} else { } else {
. "$MDTPath\_Scripts\Credentials-MDTJoinDomain.ps1" . "$MDTPath\_Scripts\Credentials-MDTJoinDomain.ps1"
Write-Host "Domain joining to generic Computers OU" Write-Host "Domain joining to generic Computers OU"

View File

@@ -1,79 +1,87 @@
# Testing MDT bullshit # Script to join domain inside of MDT.
# Technolog Networks # Technolog Networks, 2024-08-12
# iRaven # iRaven
$CompName = $env:COMPUTERNAME
Start-Transcript -Path "c:\$CompName-TESTScript.log" -Append
# General necessities. # General necessities.
$CompName = $env:COMPUTERNAME
$TSEnv = New-Object -ComObject Microsoft.SMS.TSEnvironment $TSEnv = New-Object -ComObject Microsoft.SMS.TSEnvironment
$MDTPath = $Global:TSEnv.Value("DeployRoot")
Start-Transcript -Path "$MDTPath\_Logs\$CompName-JoinDomain.log" -Append
$CompType = $args[0] $CompType = $args[0]
$SubType = $args[1] $SubType = $args[1]
Write-Host "Username: $env:username" Function CheckDomainJoin { # Check if we're already domain joined
Write-Host "MDT DeployRoot: $Global:TSEnv.Value("DeployRoot")" if ((gwmi Win32_ComputerSystem).partofdomain -eq $true -and (gwmi Win32_ComputerSystem).domain -eq "technolog.net") {
$MDTun = [System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($Global:TSEnv.Value("SMSConnectNetworkFolderAccount"))) write-host "Already part of the domain!"
Write-Host "MDT UserName: $MDTun" return true
Read-Host -Prompt "Balls..."
if ($CompType -like "WKS") {
$PCNamePrefix = ($CompName.Substring(0,$CompName.IndexOf("-")))
# Domain credentials to join WKS to domain
$MDTPath = $Global:TSEnv.Value("DeployRoot")
. "$MDTPath\_Scripts\Credentials-MDTJoinDomain.ps1"
Write-Host "Auto-detecting computer name $CompName..."
# Filter out OUs
if ($PCNamePrefix -like "XH") {
Write-Host "Detected computer name as XH - domain joining to Personal WKS OU"
$DomainOU = "OU=Personal,OU=Workstations,DC=technolog,DC=net"
}
elseif ($PCNamePrefix -like "TNG" -or $PCNamePrefix -like "NH" -or $PCNamePrefix -like "IR") {
Write-Host "Detected computer name as TNG, NH, or IR - domain joining to Standard WKS OU"
$DomainOU = "OU=Workstations,DC=technolog,DC=net"
}
elseif ($PCNamePrefix -like "TEST") {
Write-Host "Detected computer name as TEST - domain joining to Testing WKS OU"
$DomainOU = "OU=TestingWKS,OU=Workstations,DC=technolog,DC=net"
}
else {
Write-Host "Computer name is unusual - domain joining to Standard WKS OU"
$DomainOU = "OU=Workstations,DC=technolog,DC=net"
}
} elseif ($CompType -like "Server") {
$DomainCredential = Get-Credential -Message "To join this server to the domain, enter your domain credentials."
# Filter out SubType var for server tiers
if ($SubType -ne $null) {
$DomainOU = "OU=$SubType,OU=Domain Servers,DC=technolog,DC=net"
} else { } else {
$DomainOU = "OU=Domain Servers,DC=technolog,DC=net" write-host "Not part of the domain yet (or joined to another)!"
} return false
} elseif ($CompType -like "Utility") {
. "z:\_Scripts\Credentials-MDTJoinDomain.ps1"
Write-Host "Domain joining to Utility OU"
$DomainOU = "OU=Utility,DC=technolog,DC=net"
} else {
. "z:\_Scripts\Credentials-MDTJoinDomain.ps1"
Write-Host "Domain joining to generic Computers OU"
}
if ([boolean](get-variable "DomainOU" -ErrorAction SilentlyContinue)) {
try {
Add-Computer -DomainName technolog.net -Credential $DomainCredential -OUPath $DomainOU -Restart
} catch {
Write-Host "Couldn't join the domain with OU $DomainOU"
}
}
else {
try {
Add-Computer -DomainName technolog.net -Credential $DomainCredential -Restart
} catch {
Write-Host "Couldn't join the domain!"
} }
} }
Function FilterComputerOU {
if ($CompType -like "WKS") {
New-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\LSA" -Name NetJoinLegacyAccountReuse -Value 1
$PCNamePrefix = ($CompName.Substring(0,$CompName.IndexOf("-")))
# Domain credentials to join WKS to domain
. "$MDTPath\_Scripts\Credentials-MDTJoinDomain.ps1"
Write-Host "Auto-detecting computer name $CompName..."
# Filter out OUs
if ($PCNamePrefix -like "XH") {
Write-Host "Detected computer name as XH - domain joining to Personal WKS OU"
$Script.DomainOU = "OU=Personal,OU=Workstations,DC=technolog,DC=net"
}
elseif ($PCNamePrefix -like "TNG" -or $PCNamePrefix -like "NH" -or $PCNamePrefix -like "IR") {
Write-Host "Detected computer name as TNG, NH, or IR - domain joining to Standard WKS OU"
$Script.DomainOU = "OU=Generic,OU=Workstations,DC=technolog,DC=net"
} elseif ($PCNamePrefix -like "TEST") {
Write-Host "Detected computer name as TEST - domain joining to Testing WKS OU"
$Script.DomainOU = "OU=TestingWKS,OU=Workstations,DC=technolog,DC=net"
} else {
Write-Host "Computer name is unusual - domain joining to Standard WKS OU"
$Script.DomainOU = "OU=Workstations,DC=technolog,DC=net"
}
} elseif ($CompType -like "Server") {
$DomainCredential = Get-Credential -Message "To join this server to the domain, enter your domain credentials."
# Filter out SubType var for server tiers
if ($null -ne $SubType) {
$Script.DomainOU = "OU=$SubType,OU=Domain Servers,DC=technolog,DC=net"
} else {
$Script.DomainOU = "OU=Domain Servers,DC=technolog,DC=net"
}
} elseif ($CompType -like "Utility") {
. "$MDTPath\_Scripts\Credentials-MDTJoinDomain.ps1"
Write-Host "Domain joining to Utility OU"
$Script.DomainOU = "OU=Utility,OU=Workstations,DC=technolog,DC=net"
} else {
. "$MDTPath\_Scripts\Credentials-MDTJoinDomain.ps1"
Write-Host "Domain joining to generic Computers OU"
}
}
Function JoinDomainOU {
# Perform domain join with filtered OU from above
if ([boolean](get-variable "DomainOU" -ErrorAction SilentlyContinue)) {
try {
Add-Computer -DomainName technolog.net -Credential $DomainCredential -OUPath $DomainOU -Restart
} catch {
Write-Host "Couldn't join the domain with OU $DomainOU"
}
} else {
try {
Add-Computer -DomainName technolog.net -Credential $DomainCredential -Restart
} catch {
Write-Host "Couldn't join the domain!"
}
}
}
if ((CheckDomainJoin) -eq $false) {
FilterComputerOU
JoinDomainOU
}
Stop-Transcript Stop-Transcript