Category: Codes

Enable Jumbo Frames on a Windows Host

Overview: Whether the engineer or sysadmin works in the realm of 'networking', 'database', or 'Windows',…

Quick Script to Test SharePoint Online Credentials

$principle = "[email protected]" $password = 'PASSW0RT' $sharePointUrl = "https://SOMESHAREPOINT.COM/SitePages/Home.aspx" $credential=New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $principle,$(ConvertTo-securestring $password…

PowerShell: Audit Failed Logins of A User

$username='rambo' function auditLockouts($userName,$domainController,$refreshMinutes=1){ function getLockouts($domainControler){ # Requirement: # Domain Controllers Audit Group Policy has been…

PowerShell: Create SMB Share and Grant NTFS Access

$localPath="C:\testShare" $fullAccessAccounts='everyone','authenticated users' function createSmbShare($localPath,$fullAccessAccounts){ $ErrorActionPreference='stop' try{ # First, create SMB Share $smbShareName=split-path $localPath -leaf…

WinRM Issues Caused by Service Principal Name (SPN) HTTP Protocol & Port Associations

Solution as Code: There is no easy solution to this problem. Certain IIS Pool Accounts…

Using Telnet and PowerShell to Test SMTP Relay

PowerShell Method: Example of Failure: PS C:\> sendTestEmail '[email protected]' 'password' '[email protected]'Detected MX Record : ywpjf4z5siycosmh7uqymtuygcjehuc67wa6o4rq4k2a3g2aodma.mx-verification.google.comKnown…

PowerShell: Add Root Domain to Trusted Sites

Windows Servers often have 'hard admin' modes, where accesses to external websites are painstakingly restricted.…

PowerShell: Convert CSV Into HashTable

This is an illustration of a function to convert a set of CSV contents into…

PowerShell: Extract Root Domain from URL

Please note that this function requires an updated variable named $domainsDictionary. Since LTD's are being…

PowerShell: Set Enhanced Protected Mode of Internet Explorer

function changeIeProtectedMode{ # $hives = 0..4|%{"HKLM:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\$_"} $hives = 0..4|%{"HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\$_"} $keyName='2500' # Key Name…

PowerShell: Get Try Catch Exception Type of a Function

# This function will return the exception type so that it could be specified on…

PowerShell: Generate Random Password

Previous version that does not require System.Web assembly: https://blog.kimconnect.com/powershell-randompassword-function/ # This function will quickly generate…

PowerShell: Get NIC MTU’s of All Hyper-V Hosts in Domain/Forest

# listHyperVHostsInForests.ps1 # Version: 0.02 function listHyperVHostsInForests{ # Ensure that AD management module is available…

PowerShell: Use Selenium Drivers to Automate Logins

Set Variables: $username='testrobot' $password='password' $url='https://blog.kimconnect.com' # Version 0.0.2 - return true or false, while keeping…

PowerShell: Audit Domain Controller Certificates

function auditDcCerts{ try{ write-host "Gathering Domain Controller Names..." Import-Module ActiveDirectory $osInfo = Get-CimInstance -ClassName Win32_OperatingSystem…

Deploying LDAP / Active Directory Self Service Password Portal

Overview: There are several choices of platforms to deploy Password Manager: Kubernetes, Docker, Windows, and…

PowerShell: 1-Liner to Change Computer Name and Join Active Directory

# The 1-liner Add-Computer -DomainName 'somedomain.com' -credential kimconnect.com\domainadmin1 -ComputerName $env:computernname -newname 'NewName' -restart # Quick…

Hyper-V: Cloning a Virtual Machine

Update 11/25/2021: There's anther variation of this function at: https://blog.kimconnect.com/powershell-create-hyper-v-guest-vm-from-virtual-disk-vhdx/This function will dynamically detect source…

Terminal Service Auditing – Generate Report of RDP Sessions with Certain Login Dates

# getLoginEvents.ps1 function getLoginEvents{ param( $computername=$env:computername, $daysLimit=30 ) $ErrorActionPreference='stop' try{ $logins=Get-WinEvent -ComputerName $ComputerName -LogName "Microsoft-Windows-TerminalServices-LocalSessionManager/Operational"|…

How to Remove Question Mark ‘Info’ Button in SyntaxHighlighter

If you're looking for a way to remove this subtle, yet spammy link: Do this:Goto…