Month: February 2020

PowerShell: Add Quorum to Clusters

# SetClusterQuorum.ps1$clustersAndQuorums=@();$clustersAndQuorums+=[PSCustomObject]@{ClusterName='CLUSTER1';Quorum='\\FILESHERVER007\CLUSTER1$'};$clustersAndQuorums+=[PSCustomObject]@{ClusterName='CLUSTER2';Quorum='\\FILESHERVER007\CLUSTER2$'};function getViableNode{ param($nodes) foreach ($node in $nodes){ $bingo=Test-NetConnection $node -InformationLevel Quiet; if($bingo){return $node} }}…

PowerShell: Some Tricks in Using the Here-String to Declare Blocks of Code

Trigger COMMAND CLI from within PowerShell # Fastest way to list all files in a…

PowerShell: Remove an A-Host Record within Active Directory Integrated DNS Domain

Warning: this code is NOT 'production ready'. Please review and test on DEV environments carefully…

PowerShell: Add Accounts into Local Administrators Group

# addAccountToLocalAdmins.ps1# Requires: PowerShell Version 4.0+$accountToAdd='ServerAdmins'$groupName="Administrators"$servers=@( "CONCU1", 'CONCU2', 'CONCU100', 'CONCU80665', 'CONCU6547354', 'CONWHAT989', 'CONCU3')$servers|%{ $session=new-pssession $_…

PowerShell: Setting WSUS Registry Setting On/Off for Client Windows

# setWsusOnOff.ps1function setWsus{ param( [switch]$on, [switch]$off ) function wuRegistryIsOn{ # Check if this machine has…

PowerShell: Special Parameter datatype [switch]

# Demo of a simple function to turn lights on and offfunction setLight{ param( [switch]$on,…

PowerShell: Check DotNet Framework on Windows

function checkDotNetVersions{ # General info: # - Powershell 2.0 latest SSL version support is TLS…

PowerShell: Fix Clustered Disk Errors

# fixClusterDiskErrors.ps1function selectClusterName{ param($domainName=$env:USERDNSDOMAIN) write-host "Now scanning $domainName for all available cluster names. This may…

PowerShell: Generate Report of Users and Computers That Have Not Logged On for X Days

# AccountsNotLoginXDays.ps1# Set days$lastLogonDaysExceeding = 120# Gather Users$daysRange = (get-date).adddays(-$lastLogonDaysExceeding)$users=Get-ADUser -properties * -filter {(enabled -eq…

PowerShell: Change Windows Autolock

# Disable_AutoLock.ps1function changeAutoLock{ param ( [Switch]$disable, [Switch]$enable ) $registryHive = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization" $registryKey="NoLockScreen" $keyItem = Get-ItemProperty…

Windows 2012: How To Install DotNet Framework 2.0 & 3.0

If there're HTTPS/TLS issues, run this function: https://blog.kimconnect.com/powershell-enable-tls-1-2-on-legacy-servers/ Toggle WSUS registry key to off prior…

PowerShell: Windows Defender Controlled Folder Access

# Default Setting of Windows Defender:PS C:\Windows\system32> get-mppreferenceAttackSurfaceReductionOnlyExclusions :AttackSurfaceReductionRules_Actions :AttackSurfaceReductionRules_Ids :CheckForSignaturesBeforeRunningScan : FalseCloudBlockLevel : 0CloudExtendedTimeout…

PowerShell: An Exercise in Calculating Checksums

$out = new-object byte[] 1073741824; #1GB(new-object Random).NextBytes($out);[IO.File]::WriteAllBytes($dummyFile, $out);Measure-command{$hash=jacksum -a crc8 -x $dummyFile}write-host $hash# New ServerPS…

PowerShell: Enable TLS 1.2 on legacy servers

# Enable TLS 1.2 on legacy servers function enableTls12{ $windowsVersionNumber=[System.Environment]::OSVersion.Version.Major; #$windowsName=(Get-CimInstance -ClassName Win32_OperatingSystem).Caption; #The term…