Category: Codes

PowerShell: Discover Domain Controllers and Classify Each As VM or Physical

Current Version $dcObjects=Get-ADDomainController -Filter * | select Name,OperationMasterRolesforeach ($dc in $dcObjects){ $dcName=$dc.Name $dcRole=$dc.OperationMasterRoles try{ $machineModel=(Get-WmiObject…

Veeam: Hyper-V ConfigStoreRootPath Errors

Error Message ---------------------------Veeam Backup and Replication---------------------------ConfigStoreRootPath cluster parameter is not defined. We will not be…

PowerShell: Install RSAT

What problem does this solve? dcdiag /test:dns dcdiag : The term 'dcdiag' is not recognized…

PowerShell: Export Exchange Mailboxes

Export 1 mailbox $userAlias="kungfu.panda"$storageUNC="\\FILESHERVER01\Backups\PSTs"# Import Exchange Management PowershellAdd-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn;$mailboxRequest=(New-MailboxExportRequest -Mailbox $userAlias -FilePath "$storageUNC\$userAlias.pst").Mailboxfunction monitorCompletion($check){ $migrationStatus=(Get-MailboxExportRequest…

PowerShell: Recover Deleted Active Directory Objects

$domain="kimconnect"$ltd="com"$dc="dc01"$userToRecover="Tom Cruise"# Enable Active Directory Recycle Bin# Enable-ADOptionalFeature 'Recycle Bin Feature' -Scope ForestOrConfigurationSet -Target "$domain.$ltd"…

PowerShell: Office 365 Bulk Licensing, Changing IDs, Enabling POP3

Connect to Office 365 # Office 365 Global Admin Credential$username="O365globalAdmin"$password=ConvertTo-securestring "PASSWORDHERE" -AsPlainText -Force$cred = New-Object…

PowerShell: Fix Email Aliases as Preparation for O365 Migration

Check SMTP Addresses of On Premise Mailboxes function checkSmtpAddresses{ $microsoftDomain1="@kimconnect.mail.onmicrosoft.com" $microsoftDomain2="@kimconnect.onmicrosoft.com" $dotLocal=".local" $onpremMailboxes=Get-Mailbox -ResultSize unlimited…

Excel Challenge: Update Records with a New Email Domain if It Matches Deprecated Domain

PrimaryEmail (Cell B2) EmailUsername Domain [email protected] =LEFT(B2,FIND("@",B2)-1) =RIGHT(B2,LEN(B2)-FIND("@",B2)) FixedPrimaryEmail =IF(D2="olddomain.org",C2&"@newdomain.org",B2)

PowerShell: Obtain List of Hyper-V Hosts in All Domains of All Forests

Version 0.03: https://blog.kimconnect.com/powershell-obtain-list-of-hyper-v-hosts-via-active-directory/ Version 0.02: https://blog.kimconnect.com/powershell-get-nic-mtus-of-all-hyper-v-hosts-in-domain-forest/ Previous version: # listHyperVHostsInForests.ps1# version 0.01# This function scans…

PowerShell: Windows Automated Disk Cleanup

##################################################################################     <#      This script is created to automate the cleanup activity. Doing so will benefit to reduce the size of disk.     This script will perform the following   1. Clear windows temp and user temp folder   2. Empty recycle bin   3. Disk Cleanup   4. Clear CBS cabinet log files   5. Clear downloaded patches   6. Clear downloaded driver   7. Clean download folder      Note:  …

PowerShell: Exchange 2010 Server Update & Restart

function stopExchange{ net stop msexchangeadtopology /y net stop msexchangefba /y net stop msftesql-exchange /y net…

PowerShell: Windows 10 Preparation Script

Set PowerShell execution policy prior to running script as an Administrator Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Confirm:$False…

PowerShell: Script to Send Emails

In the past, a simple email relay script was sufficient to spool internal messages. However,…

PowerShell: Practical Usage of Robocopy

Quick Commands: $source='C:\vssSnapshot_F'$destination='\\DESTINATIONSERVER\F$'robocopy $source $destination /E /R:0 /NP /XD '$RECYCLE.BIN' 'System Volume Information' /xf 'pagefile.sys'…

PowerShell: Administering Network Time Protocol Settings on Windows

Quick Script of Domain Joined Laptops and Desktops for Remote Users: # Set Domain Joined…

Manually Create a SSL Certificate with LetsEncrypt

Step 1: Install certbot-auto mkdir /etc/letsencryptcd /etc/letsencrypt/wget chmod a+x certbot-auto Step 2: Create the Cert…

PowerShell Commands to Discover the Server Network, Netmask, DHCP status, and Gateway

$servername = "SERVER01"get-wmiobject win32_networkadapterconfiguration -computername $servername -ea stop | ? {$_.IPEnabled}# Result:DHCPEnabled      :…

Cisco Fabric Switch – MDS Zoning Template

<# What this script does: 1. Checks to see if an Internet connection via PowerShell…

PowerShell: Microsoft SQL Administration

Script to Install Microsoft Clustering Service $proxy="http://proxy:8080"$exclusionList="localhost;*.kimconnect.com"function checkProxy{try{$connectionTest=iwr download.microsoft.com#$connectionSucceeds=Test-NetConnection -Computername download.microsoft.com -Port 443 -InformationLevel Quietif…

PowerShell: Use Chocolatey to Install Apps on Windows (Similar to Apt-Get or Yum)

Quick installation paste: # Install Chocolateyif (!(Get-Command choco.exe -ErrorAction SilentlyContinue)) {[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12Set-ExecutionPolicy Bypass -Scope…