Category: Codes

PowerShell: Check IP Conflicts of Computers in Active Directory

We have ran into issues where a group of virtual machines living on a DHCP…

How to Obtain Mac Address of Remote Computer

# PowerShell $computername='TESTSERVER' Get-CimInstance -ClassName Win32_NetworkAdapterConfiguration -Filter "IPEnabled='True'" -ComputerName $computername|Select-Object -Property MACAddress, Description # Sample…

PowerShell: Set PasswordNeverExpires on SamAccountName

Quick 1-liner Code $accounts=@( 'orange', 'apple', 'pear', 'dog', 'cat', 'dinosaur', 'chicken', 'cow', 'yomama', 'yodada' )…

Convert LastLogon Date From Number to Date Time

We have a case where our Admins have generated a CSV file with information about…

Quick & Useful Snippet to Set SSL TLS Protocol of PowerShell

$requiredTls='Tls12' $availableSslProtocols=[enum]::getnames([net.securityprotocoltype]) if([Net.ServicePointManager]::SecurityProtocol -notin $requiredTls -and $requiredTls -in $availableSslProtocols){ [Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::$requiredTls }

An Exercise in Discover Whether an Active Directory Account Has RDP Access to Windows Bastion Hosts

Check Computers: $computernames='RDPSERVER01','RDPSERVER02','RDPSERVER03' invoke-command -computername $computernames {get-localgroupmember 'remote desktop users'}|select PSComputername,Name # Sample output PS…

Indications that Chocolatey is locked down

# System's version is less than vendor's current (Chocolatey v0.10.15) 0+000+00[LAX-WEB005]: PS C:\Users\testadmin\Documents> choco source…

How To Upgrade NextCloud 22.1.1 to 22.2.0 When Deployed with Kubernetes & Helm

Step 1: Navigate to nextcloud > html > edit version.php <?php $OC_Version = array(22,1,1,2); $OC_VersionString…

WordPress: How To Add Custom XML Sitemap to Yoast SEO

Step 1: Install Yoast SEO Step 2: Install Code Snippets Step 3: Add this Snippet…

Kubernetes: Cert-Manager x509 ECDSA verification failure

Symptoms Error from server (InternalError): error when creating "kimconnect-cert.yaml": Internal error occurred: failed calling webhook…

Kubernetes: Cert-Manager Certificate Request YAML Example

# Set variables certPrefix=kimconnect domainName=kimconnect.com domainName2=www.kimconnect.com serviceName=kimconnectblog-wordpress servicePort=8080 # Create a yaml file and create…

PowerShell: Obtain List of Hyper-V Hosts via Active Directory

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

Linux: How To Use Dig

Checking Name Server(s) kim@kim-linux:~$ dig @8.8.8.8 microsoft.com ; <<>> DiG 9.16.1-Ubuntu <<>> @8.8.8.8 microsoft.com ;…

Bash Shell: Rename Files – Prepend and Append

Pre-pending # Prepend any file that doesn't have the word "/thumbs_" in its full path…

PowerShell: Add User To Group in Active Directory

$userId='kimconnect' $groupName='Remote Desktop Users' function addUserToGroup($userId,$groupName){ $userExists=Get-ADGroupMember $groupName|?{$_.SamAccountName -eq $userId} if(!$userExists){ Add-ADGroupMember -Identity $groupName -Members…

Domain Name Records Overview: A-record, MX, DKIM, SPF, SRV

A RECORD (A-host): - What: address record (A-record) specifies the IP address(es) of a given…

How To Improve WordPress Website Rendering Speed

These are the recommended plug-ins to enable caching, database cleaning, image compressing, and minify codes…

Bash: How To Join Array With Comma Delimiter

# The following function joins an array of numbers # Limitation: the delimiter is expected…

PowerShell: Reset Active Directory User Password

# User input variables $adminUsername='intranet\kim-a' $adminPassword='SOMECOMPLEXPASSWORD' $userId='kim' $newPassword='SOMECOMPLEXPASSWORD' $domainController='intranet.kimconnect.com' # Auto-gen Variables $encryptedPassword=ConvertTo-SecureString $adminPassword -AsPlainText…

PowerShell: Notify Each User Before Password Expires

# This script email users basing on their password expiration dates # User input variables…