minor rearranging
This commit is contained in:
@@ -9,11 +9,11 @@ $CompName = $env:COMPUTERNAME
|
||||
$ADCompOU = ([adsisearcher]"(&(objectClass=computer)(sAMAccountName=$CompName$))").FindOne().GetDirectoryEntry().distinguishedName
|
||||
$PCNamePrefix = ($CompName.Substring(0,$CompName.IndexOf("-")))
|
||||
$PCNameSuffix = ($CompName.Substring($CompName.IndexOf("-")+1))
|
||||
# Domain Credentials to be used
|
||||
. "\\berrypunch.technolog.net\PSCredentials$\Credentials-WKSDeploy.ps1"
|
||||
|
||||
Function RenamePCTNGPrefix {
|
||||
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
|
||||
}
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
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]
|
||||
|
||||
# Office Install Checks
|
||||
@@ -18,7 +18,7 @@ $Office2024 = (Get-WmiObject -Class Win32_Product | where name -like "Microsoft
|
||||
Function CheckInstall {
|
||||
if ($null -ne $OfficeVersionInstalled) {
|
||||
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."
|
||||
return $true
|
||||
} elseif ($null -ne $Office2019 -and $ParamVersion -eq 2019) {
|
||||
|
@@ -15,7 +15,7 @@ $ZabbixServer = "10.10.0.90"
|
||||
$ZabbixAgentLogFile = "$InstallFolder\zabbix_agentd.log"
|
||||
|
||||
Function CheckZabbixInstall {
|
||||
if ($ZabbixVersionInstalled -ne $null) {
|
||||
if ($null -ne $ZabbixVersionInstalled) {
|
||||
if ($ZabbixVersionInstalled -like "$SDZabbixVersion*") {
|
||||
return $true
|
||||
} else {
|
||||
|
@@ -30,6 +30,10 @@ if ($CompType -like "WKS") {
|
||||
Write-Host "Detected computer name as TEST - domain joining to Testing WKS OU"
|
||||
$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 {
|
||||
Write-Host "Computer name is unusual - domain joining to Standard WKS OU"
|
||||
$DomainOU = "OU=Workstations,DC=technolog,DC=net"
|
||||
@@ -46,7 +50,7 @@ if ($CompType -like "WKS") {
|
||||
. "$MDTPath\_Scripts\Credentials-MDTJoinDomain.ps1"
|
||||
|
||||
Write-Host "Domain joining to Utility OU"
|
||||
$DomainOU = "OU=Utility,DC=technolog,DC=net"
|
||||
$DomainOU = "OU=Utility,OU=Workstations,DC=technolog,DC=net"
|
||||
} else {
|
||||
. "$MDTPath\_Scripts\Credentials-MDTJoinDomain.ps1"
|
||||
Write-Host "Domain joining to generic Computers OU"
|
||||
|
@@ -1,79 +1,87 @@
|
||||
# Testing MDT bullshit
|
||||
# Technolog Networks
|
||||
# Script to join domain inside of MDT.
|
||||
# Technolog Networks, 2024-08-12
|
||||
# iRaven
|
||||
|
||||
$CompName = $env:COMPUTERNAME
|
||||
Start-Transcript -Path "c:\$CompName-TESTScript.log" -Append
|
||||
|
||||
# General necessities.
|
||||
$CompName = $env:COMPUTERNAME
|
||||
$TSEnv = New-Object -ComObject Microsoft.SMS.TSEnvironment
|
||||
|
||||
$MDTPath = $Global:TSEnv.Value("DeployRoot")
|
||||
Start-Transcript -Path "$MDTPath\_Logs\$CompName-JoinDomain.log" -Append
|
||||
$CompType = $args[0]
|
||||
$SubType = $args[1]
|
||||
|
||||
Write-Host "Username: $env:username"
|
||||
Write-Host "MDT DeployRoot: $Global:TSEnv.Value("DeployRoot")"
|
||||
$MDTun = [System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($Global:TSEnv.Value("SMSConnectNetworkFolderAccount")))
|
||||
Write-Host "MDT UserName: $MDTun"
|
||||
|
||||
Read-Host -Prompt "Balls..."
|
||||
Function CheckDomainJoin { # Check if we're already domain joined
|
||||
if ((gwmi Win32_ComputerSystem).partofdomain -eq $true -and (gwmi Win32_ComputerSystem).domain -eq "technolog.net") {
|
||||
write-host "Already part of the domain!"
|
||||
return true
|
||||
} else {
|
||||
write-host "Not part of the domain yet (or joined to another)!"
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
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 = $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"
|
||||
$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"
|
||||
$DomainOU = "OU=Workstations,DC=technolog,DC=net"
|
||||
}
|
||||
elseif ($PCNamePrefix -like "TEST") {
|
||||
$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"
|
||||
$DomainOU = "OU=TestingWKS,OU=Workstations,DC=technolog,DC=net"
|
||||
}
|
||||
else {
|
||||
$Script.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"
|
||||
$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 ($SubType -ne $null) {
|
||||
$DomainOU = "OU=$SubType,OU=Domain Servers,DC=technolog,DC=net"
|
||||
if ($null -ne $SubType) {
|
||||
$Script.DomainOU = "OU=$SubType,OU=Domain Servers,DC=technolog,DC=net"
|
||||
} else {
|
||||
$DomainOU = "OU=Domain Servers,DC=technolog,DC=net"
|
||||
$Script.DomainOU = "OU=Domain Servers,DC=technolog,DC=net"
|
||||
}
|
||||
} elseif ($CompType -like "Utility") {
|
||||
. "z:\_Scripts\Credentials-MDTJoinDomain.ps1"
|
||||
. "$MDTPath\_Scripts\Credentials-MDTJoinDomain.ps1"
|
||||
|
||||
Write-Host "Domain joining to Utility OU"
|
||||
$DomainOU = "OU=Utility,DC=technolog,DC=net"
|
||||
$Script.DomainOU = "OU=Utility,OU=Workstations,DC=technolog,DC=net"
|
||||
} else {
|
||||
. "z:\_Scripts\Credentials-MDTJoinDomain.ps1"
|
||||
. "$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 {
|
||||
} 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
|
Reference in New Issue
Block a user