Initial Commit
This commit is contained in:
28
Computer-NameScheme.ps1
Normal file
28
Computer-NameScheme.ps1
Normal file
@@ -0,0 +1,28 @@
|
||||
# Script to change computer name matching new naming scheme as of 2024-06.
|
||||
# Technolog Networks - 2024-07-26
|
||||
# iRaven
|
||||
|
||||
Start-Transcript -Path "c:\irnh\Computer-NameScheme.log" -Append
|
||||
|
||||
# General necessities.
|
||||
$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."
|
||||
Rename-Computer -NewName "TNG-$PCNameSuffix" -DomainCredential $DomainCredential -Restart
|
||||
}
|
||||
|
||||
if ($PCNamePrefix -like "NH" -or $PCNamePrefix -like "IR") {
|
||||
RenamePCTNGPrefix
|
||||
} elseif ($ADCompOU -like "*Personal*" -Or ($PCNamePrefix -like "XH")) {
|
||||
Write-Host "This is an XH system, we shall not change anything."
|
||||
} else {
|
||||
echo "Computer name is valid; not making changes."
|
||||
}
|
||||
|
||||
Stop-Transcript
|
Reference in New Issue
Block a user