Author: kimconnect

Dev Environment Technitium DNS Server

Windows: $technitiumPortableDownload="https://download.technitium.com/dns/DnsServerPortable.zip"$tempDir="C:\Temp"; $extractionDir="C:\Technitium" $destinationFile = "$tempDir\DnsServerPortable.zip"; try{[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12}catch{} New-Item -ItemType Directory -Force -Path $tempDir…

PowerShell: Quick 1-Liner to Check Status of URL

The kommand: Invoke-WebRequest "https://blog.kimconnect.com" -MaximumRedirection 0 -ErrorAction SilentlyContinue | Select-Object StatusCode,StatusDescription Sample Result: StatusCode StatusDescription----------…

PowerShell: Generate a CSV Report of O365 Exchange Online Mailboxes

# Office 365 Global Admin Credential$username="[email protected]"$password=ConvertTo-securestring "PASSWORD" -AsPlainText -Force$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username,$passwordfunction…

PowerShell: Connect to Office 365 Exchange Online

function disconnectExchangeOnline{ <# manually check sessions PS C:\Windows\system32> Get-PSSession Id Name ComputerName ComputerType State ConfigurationName…

PowerShell: Get Executable Version and File Location

# Quick method to obtain computernames of all nodes in a cluster and adjoin result…

PowerShell: Add System Backup Privileges

function addSystemPrivilege{ param( [String[]]$privileges=@("SeBackupPrivilege","SeRestorePrivilege") ) function includeSystemPrivileges{ $win32api = @' using System; using System.Runtime.InteropServices; namespace…

PowerShell: Enable ISE

Import-Module ServerManager;Add-WindowsFeature PowerShell-ISE

PowerShell: Deleting a Single File Safely

# Name your file$item="\\FILESHERVER007\someweird folder names with long paths\ fmmkklghhbb-yj-yuyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy p-hphlfiles\whatup.exe - Shortcut.lnk" #item could…

Active Directory GPO Practical Examples

Fonts Distribution---------------------------------A. Create an SMB share on an Intranet accessible directory \\SOFTWARE\FONTS\Kim-Connect.ttfB. Create a new…

PowerShell: Increase Default Windows 260-Character Paths Limit

Problem: Error when trying to rename files manually:'The source files name(s) are larger than is…

PowerShell: Windows Systems State Backup Daily

# Windows-Systems-State-Backup-V0.1.ps1## What this script does:# 1. Create a Windows Scheduled task on an Active…

PowerShell: How to Properly Delete a Msol User Account

# Set the user ObjectID attribute variable$msolUser="6f2fcfcd-...."# Move user account to Recycle BinRemove-MsolUser -ObjectId $msolUser#…

PowerShell: Play with Time

1. Constructor: $timer=[System.Diagnostics.Stopwatch]::StartNew() 2. Accessing a property $totalSeconds=$timer.Elapsed.TotalSeconds 3. Output Time (Usage): $hours=[math]::round($totalSeconds/3600,2)write-host "It has…

PowerShell: Accessing the Reflection Assembly Class to Retrieve User Context

Step 1: Accessing Reflection Assembly namespace to call method Load with Windows Account Management as…

PowerShell: Detect Antivirus Name on a Windows Machine

function getAntivirusName { $wmiQuery = "SELECT * FROM AntiVirusProduct" $antivirus = Get-WmiObject -Namespace "root\SecurityCenter2" -Query…

PowerShell: How To Add Additional Sub-Directories to an Existing SMB Share

Business Use-Case: There's an existing logon script or Group Policy that maps users toward a…

PowerShell: Synchronize Files Between Different Domains

<# File_Copy_Script_UNC_to_Local_V0.1.ps1Purpose: connect to an external domain to copy files onto a Intranet server.Features:- Synchronize…

PowerShell: Benchmark Disk Speed

Contrary to previous iteration, this version returns an object with multiple properties describing statistical analysis…

Bash Shell: Old School Migration of ESXi Guest Virtual Machines

Step 0: Preparations Estimate file-copying duration for cut-over:- Sustained storage transfer speed using a 1GB…

PowerShell: List Currently Logon Users On Remote Servers

# Show current sessions on a list of servers$servers="SHERVER005","SHERVER007";$servers|%{"$_`n$(query user /server:$_|Out-String)"} # Sample OutputPS C:\Windows\system32>…