Author: kimconnect

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…

PowerShell: Setting or Resetting User Password

$username='dragoncoin' $newPassword='SomeComplexPasswordHere' function resetPassword($username,$password){ if($env:userdnsdomain){ try{ Unlock-ADAccount -Identity $username Set-ADAccountPassword -Identity $username -Reset -NewPassword (ConvertTo-SecureString…

PowerShell: Regex Examples

# Example 1 Simple 10-digit match $x='123-456-7890' [regex]$regex10Digits='\({0,1}\d{0,1}\){0,1}\-{0,1}(\d{3})' $areaCode=$regex10Digits.Match($x).Groups[1].Value # Example 2 IP Version 4…

Hyper-V: Creating a New Virtual Machine

# Compulsory variables $hyperVHost='HYPERV007' $vmName='WindowsGoldenImage' $parentDirectory='C:\ClusterStorage\Volume5' $disk1Size='100GB' $memoryAllocation='8GB' $networkSwitch='PublicZone' $vlan='1005' $clusterName='DEV-CLUSTER05' # Optional variables $disk2Size=$false…

Windows Activation Methods

Overview: 1. Retail:- There are 'lifetime' and 'limited' (1-2 years) variants- This can be used…

PowerShell: WinSCP Module

$username='bongo' $port=20202 $remoteHost='dev-sftp.kimconnect.net' $privateKey='C:\scripts\keys\testkey.ppk' $remoteRoot='/' $downloadFolder='D:\downloads' $remoteDirectory='/var/www/sftp.kimconnect.net' $currentDirectory=$remoteDirectory $localFolder=(New-Object -ComObject Shell.Application).NameSpace('shell:Downloads').Self.Path $appName='winscp' function includePowerShellWrapper($appName){ #…

Latin1_General_CI_AI vs SQL_Latin1_General_CP1_CI_AS

The SQL_Latin1_General_CP1_CI_AS collation is a SQL collation and the rules around sorting data for unicode…

Memo of an Advisory Regarding WinRM on a Non-Domain Joined Server

# Enable WinRM winrm quickconfig <# Sample output PS C:\Users\Administrator> winrm quickconfig WinRM service is…

PowerShell: Enable Remote Desktop

$computernames=@' SERVER1 SERVER2 '@ $computers=@($computernames -split "`n" -replace "\..*$") function enableRemoteDesktop{ $regHiveTs='HKLM:\System\CurrentControlSet\Control\Terminal Server' $regKeyTs='fDenyTSConnections' $enable=0…

A Broken PS-Session Issue

Symptoms: PS C:\Windows\system32> get-pssession Id Name ComputerName ComputerType State ConfigurationName Availability -- ---- ------------ ------------…

WordPress Plugin Syntax Highlighter Fix

Source: from a forum poster of this plugin's Github page. // Add this to functions.php…

PowerShell: Backup, Archive, and Remove a Microsoft SQL Database

$sqlServer='sqlsherver007' $databaseName="someDatabaseName" $saCredential=get-credential $backupDestination="\\Archive03\MSSQL_Backups" function triggerSqlBackup($sqlServer,$databaseName){ # Ensure the the Jump Box has SQL PowerShell…

PowerShell: Disable Annoying Windows Updates Notifications

This little snippet would render these notices as void. # This snippet is to add…

Function to Install Application and Its PowerShell Wrapper

# This function checks on whether a particular app has a corresponding PowerShell wrapper. If…

PowerShell: Automated Login Validation Using Internet Explorer

Update April 395 A.D.: IE variances make it difficult to perform standardized automation; hence, another…