Directory Cleanup & Addition of Platform Scripts

This commit is contained in:
Andrew Amason
2025-05-14 13:25:48 -04:00
parent 5b9825e6dc
commit 1be4de9e7b
26 changed files with 1595 additions and 90 deletions

View File

@@ -0,0 +1,30 @@
Try {
$details = Get-ComputerInfo
if (-not $details.CsPartOfDomain) {
Write-Output 'Not Domain Joined'
Exit 0
}
$serial = Get-WmiObject Win32_bios | Select-Object -ExpandProperty SerialNumber
$newName = $serial
$newName = $newName.Replace(' ', '')
if ($newName.Length -ge 15) {
$newName = $newName.substring(0, 15)
}
If ($details.CsName -ne $newName) {
Write-Warning "Existing Computer name $($details.CsName) should be $newName"
Exit 1
}
Else {
Write-Output "Computer has correct name: $($details.CsName)"
Exit 0
}
}
Catch {
Write-Error $_.Exception
Exit 2000
}