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
}

View File

@@ -0,0 +1,33 @@
$domain = 'ccx.carecentrix.com'
$waitTime = '45'
Try {
$dcInfo = [ADSI]"LDAP://$domain"
if ($null -eq $dcInfo.Path) {
Write-Error "No connectivity to $domain"
}
$serial = Get-WmiObject Win32_bios | Select-Object -ExpandProperty SerialNumber
If (Get-WmiObject -Class win32_battery) {
$newName = $serial
}
Else {
$newName = $serial
}
$newName = $newName.Replace(' ', '')
if ($newName.Length -ge 15) {
$newName = $newName.substring(0, 15)
}
Rename-Computer -NewName $newName
$waitSeconds = (New-TimeSpan -Minutes $waitTime).TotalSeconds
Write-Host "Initiating a restart in $waitime minutes"
& shutdown.exe /g /t $waitSeconds /f /c "Your system requires are reboot due to a computer name change. Please save your work and either reboot now or your system will reboot in $waitTime minutes."
Write-Output "Computer renamed from $($details.CsName) to $newName"
}
Catch {
Write-Error $_.Exception
Exit 2000
}

View File

@@ -1,47 +0,0 @@
<#
Version: 1.0
Author: Jannik Reinhard (jannikreinhard.com)
Script: Move-Windows11Taskbar
Description:
Change the tastkbar alignment
Release notes:
Version 1.0: Init
#>
function Test-RegistryValue {
param (
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]$Path,
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]$Value
)
try {
Get-ItemProperty -Path $Path | Select-Object -ExpandProperty $Value -ErrorAction Stop | Out-Null
return $true
}catch {
return $false
}
}
$path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
$value = "TaskbarAl"
if(-not (Get-CimInstance Win32_OperatingSystem -Property *).Caption -like "*Windows 11*"){
Exit 0
}
if((Test-RegistryValue -Path $path -Value $value)){
if((Get-ItemProperty -path $path -name $value).TaskbarAl -eq "0"){
Exit 0
}
}else {
Exit 1
}

View File

@@ -1,41 +0,0 @@
<#
Version: 1.0
Author: Jannik Reinhard (jannikreinhard.com)
Script: Move-Windows11Taskbar
Description:
Change the tastkbar alignment
Release notes:
Version 1.0: Init
#>
function Test-RegistryValue {
param (
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]$Path,
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]$Value
)
try {
Get-ItemProperty -Path $Path | Select-Object -ExpandProperty $Value -ErrorAction Stop | Out-Null
return $true
}catch {
return $false
}
}
$path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
$value = "TaskbarAl"
if(Test-Path $path){
try{
Set-ItemProperty -Path $path -Name $value -Value 0 -Force
Exit 0
}catch{
Exit 1
}
}else{
Exit 1
}

View File

@@ -0,0 +1,31 @@
function compareRegistryValue {
param (
[string]$path,
[string]$keyName,
[string]$value
)
$currentValue = (Get-ItemProperty -Path $path -Name $keyName).$keyName
if ($currentValue -eq $value) {
return $true
} else {
return $false
}
}
$thirtyTwo = compareRegistryValue -path "HKLM:\Software\Microsoft\Cryptography\Wintrust\Config" -keyName "EnableCertPaddingCheck" -value "1"
if ((Get-WmiObject win32_operatingsystem | select osarchitecture).osarchitecture -eq "64-bit") {
$sixtyFour = compareRegistryValue -path "HKLM:\Software\Wow6432Node\Microsoft\Cryptography\Wintrust\Config" -keyName "EnableCertPaddingCheck" -value "1"
} else {
$sixtyFour = $true
}
if ($thirtyTwo -and $sixtyFour) {
Write-Output "The registry key is set to the expected value."
exit 0
} else {
Write-Output "The registry key is not set to the expected value."
exit 1
}

View File

@@ -0,0 +1,27 @@
function createRegistryKey {
param (
[string]$path
)
New-Item -Path $path -Force
}
function setRegistryKey {
param (
[string]$path,
[string]$keyName,
[string]$value
)
Set-ItemProperty -Path $path -Name $keyName -Value $value
}
createRegistryKey -path "HKLM:\Software\Microsoft\Cryptography\Wintrust"
createRegistryKey -path "HKLM:\Software\Microsoft\Cryptography\Wintrust\Config"
setRegistryKey -path "HKLM:\Software\Microsoft\Cryptography\Wintrust\Config" -keyName "EnableCertPaddingCheck" -value "1"
if ((Get-WmiObject win32_operatingsystem | select osarchitecture).osarchitecture -eq "64-bit") {
createRegistryKey -path "HKLM:\Software\Wow6432Node\Microsoft\Cryptography\Wintrust"
createRegistryKey -path "HKLM:\Software\Wow6432Node\Microsoft\Cryptography\Wintrust\Config"
setRegistryKey -path "HKLM:\Software\Wow6432Node\Microsoft\Cryptography\Wintrust\Config" -keyName "EnableCertPaddingCheck" -value "1"
}