Compare commits

..

9 Commits

Author SHA1 Message Date
1ee5438c92 do not restart on domain join with MDT 2025-10-14 01:52:19 -05:00
3f9175317c JoinDomain check 2025-10-14 01:47:49 -05:00
a8af307fea anyconnect - use get-package 2025-10-14 01:38:06 -05:00
a951e60063 AnyConnect Install script 2025-10-14 00:51:21 -05:00
080034b176 minor rearranging 2025-10-03 22:45:57 -05:00
4af8ff2fa2 moving shit around 2025-10-03 21:48:06 -05:00
d7ef359b82 Update Zabbix Agent to 7.0.19 2025-10-03 11:52:37 -05:00
bf39b4d00a Merge branch 'main' of https://git.technolog.network/technolog/scripts 2025-09-06 02:32:53 -05:00
f361e92ac8 winget update 2025-09-06 02:32:52 -05:00
22 changed files with 160 additions and 87 deletions

5
.gitignore vendored
View File

@@ -1,5 +1,2 @@
# Do not commit any credentials files.
Credentials-*.ps1
# Do not commit any phtransfer files. They can be found here: iraven/piholesync
phtransfer*
Credentials-*.ps1

View File

@@ -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
}

32
Install-AnyConnect.ps1 Normal file
View File

@@ -0,0 +1,32 @@
# Script to install AnyConnect VPN Client
# Technolog Networks - 2025-10-13
# iRaven
param(
[switch] $SBL
)
Start-Transcript -Path "c:\irnh\Install-AnyConnect.log" -Append
Function CheckInstall {
if (Get-Package -Name "Cisco*AnyConnect*") {
return $true
} else {
return $false
}
}
if ((CheckInstall) -eq $false) {
try {
Write-Host -ForegroundColor Yellow "Installing AnyConnect Core"
msiexec /i ".\CiscoAnyConnect.msi" /quiet
if ($SBL) {
Write-Host -ForegroundColor Yellow "Installing AnyConnect SBL"
msiexec /i ".\CiscoAnyConnectSBL.msi" /quiet
}
} catch {
write-host "it no worky"
}
}
Stop-Transcript

View File

@@ -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) {

View File

@@ -6,8 +6,8 @@ Start-Transcript -Path "c:\irnh\Install-ZabbixAgent.log" -Append
$InstallFolder = "C:\Program Files\Zabbix Agent"
$InstallerLog = "C:\irnh\Installer-ZabbixAgent.log"
$SoftwareDeployLocation = "\\technolog.net\sysvol\technolog.net\SoftwareDeploy\zabbix_agent-7.0.9-windows-amd64-openssl.msi"
$SDZabbixVersion = "7.0.9"
$SDZabbixVersion = "7.0.19" # Modify with latest version of zabbix agent in share below
$SoftwareDeployLocation = "\\technolog.net\sysvol\technolog.net\SoftwareDeploy\zabbix_agent-$SDZabbixVersion-windows-amd64-openssl.msi"
$ZabbixVersionInstalled = (Get-WmiObject -Class Win32_Product | where name -like "Zabbix*" | select Name, Version).Version
# Zabbix settings
@@ -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 {

View File

@@ -10,6 +10,13 @@ Start-Transcript -Path "$MDTPath\_Logs\$CompName-JoinDomain.log" -Append
$CompType = $args[0]
$SubType = $args[1]
# Check if we're already in the domain
if ((gwmi win32_computersystem).partofdomain -eq $true) {
write-host -ForegroundColor Green "Already in the domain! Exiting."
Stop-Transcript
exit 0
}
if ($CompType -like "WKS") {
New-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\LSA" -Name NetJoinLegacyAccountReuse -Value 1
$PCNamePrefix = ($CompName.Substring(0,$CompName.IndexOf("-")))
@@ -30,6 +37,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 +57,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"
@@ -55,14 +66,14 @@ if ($CompType -like "WKS") {
if ([boolean](get-variable "DomainOU" -ErrorAction SilentlyContinue)) {
try {
Add-Computer -DomainName technolog.net -Credential $DomainCredential -OUPath $DomainOU -Restart
Add-Computer -DomainName technolog.net -Credential $DomainCredential -OUPath $DomainOU
} catch {
Write-Host "Couldn't join the domain with OU $DomainOU"
}
}
else {
try {
Add-Computer -DomainName technolog.net -Credential $DomainCredential -Restart
Add-Computer -DomainName technolog.net -Credential $DomainCredential
} catch {
Write-Host "Couldn't join the domain!"
}

View File

View File

@@ -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..."
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"
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 {
$DomainOU = "OU=Domain Servers,DC=technolog,DC=net"
}
} 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!"
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\_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

View File

@@ -24,6 +24,10 @@ Function Check-VCLibs {
if ((Get-AppxPackage).Name -like "Microsoft.VCLibs.140.00.UWPDesktop" ) {return $true} else {return $false}
}
Function Check-MSXaml {
if ((Get-AppxPackage).Name -like "Microsoft.UI.Xaml*" ) {return $true} else {return $false}
}
Function Install-VCLibs {
if (Check-VCLibs) {
Write-Output "VCLibs.UWPDesktop is already installed."
@@ -38,6 +42,22 @@ Function Install-VCLibs {
}
}
}
Function Install-MSXaml {
if (Check-MSXaml) {
Write-Output "Microsoft.UI.Xaml is already installed."
} else {
cmd.exe /c "curl -L -o c:\irnh\msuixaml.zip https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml"
try {
Expand-Archive c:\irnh\msuixaml.zip
Add-AppPackage .\msuixaml\tools\AppX\x64\Release\*.appx
Write-Output "Microsoft.UI.Xaml was installed."
} catch {
Write-Output "Microsoft.UI.Xaml could not be installed."
}
}
}
Function Install-WinGet {
Write-Host "Checking latest version..."
$WGLatestVer = (irm https://api.github.com/repos/microsoft/winget-cli/releases/latest).tag_name
@@ -47,7 +67,7 @@ Function Install-WinGet {
Write-Output "Domain Controllers has the latest version $WGDomainVer; using that."
try {
Add-AppxPackage -Path "\\technolog.net\SYSVOL\technolog.net\SoftwareDeploy\winget.msixbundle"
Add-AppxProvisionedPackage -Online -PackagePath "\\technolog.net\SYSVOL\technolog.net\SoftwareDeploy\winget.msixbundle" -LicensePath "\\technolog.net\SYSVOL\technolog.net\SoftwareDeploy\wingetlic.xml"
Add-AppxProvisionedPackage -Online -PackagePath "\\technolog.net\SYSVOL\technolog.net\SoftwareDeploy\winget.msixbundle" -LicensePath "\\technolog.net\SYSVOL\technolog.net\SoftwareDeploy\wingetlic.xml" -Verbose
Write-Output "WinGet was successfully installed."
} catch {
Write-Output "WinGet could not be installed."
@@ -56,17 +76,21 @@ Function Install-WinGet {
else {
# If the version we have on our domain controllers is NOT the latest, we have to get it online.
Write-Host "Internet has the latest copy; downloading WinGet from Microsoft."
cmd.exe /c "curl -L -o c:\irnh\winget.msixbundle https://aka.ms/getwinget" # I hate IWR. lol
# download latest lic file
# download latest files
foreach ($url in (irm https://api.github.com/repos/microsoft/winget-cli/releases/latest).assets.browser_download_url){
if ($url -like "*.xml")
{cmd.exe /c "curl -L -o c:\irnh\wingetlic.xml $url"} # I hate IWR. lol
if ($url -like "*.msixbundle")
{cmd.exe /c "curl -L -o c:\irnh\winget.msixbundle $url"} # I hate IWR. lol
}
try {
# Add-AppxPackage -Path "c:\irnh\winget.msixbundle"
Add-AppxPackage -Path "c:\irnh\winget.msixbundle"
Add-AppxProvisionedPackage -Online -PackagePath "c:\irnh\winget.msixbundle" -LicensePath "c:\irnh\wingetlic.xml"
Write-Output "WinGet was successfully installed."
Add-AppxPackage -Path "c:\irnh\winget.msixbundle" -Verbose
Add-AppxProvisionedPackage -Online -PackagePath "c:\irnh\winget.msixbundle" -LicensePath "c:\irnh\wingetlic.xml" -Verbose
$winget = winget -v
if ($winget) {
Write-Output "WinGet was successfully installed."
}
} catch {
Write-Output "WinGet could not be installed."
}
@@ -77,6 +101,7 @@ Function Install-WinGet {
if (!(Check-WinGet-Install)) {
Install-VCLibs
Install-MSXaml
Install-WinGet
}
Stop-Transcript