Category: Codes

PowerShell: List All IPs Used by Cluster

Snippet: # Obtain IPs of resources in clusterfunction getResourceIPs { $resourceIPs=Get-Cluster | Get-ClusterResource | ?{$_.ResourceType…

PowerShell: Setup Windows Scheduled Tasks

Outdated script. Use something else by searching this blog further. # scheduledTasksRemote_V0.0.2.ps1# Purpose: to add…

PowerShell: Scan a Subnet for Used and Unused IPs

A newer version of this script is available here. function scanForAvailableIPs{ param( $cidrBlock=$( $interfaceIndex=(Get-WmiObject -Class…

1-Liner to Find Host of Virtual Machine in Hyper-V

PS C:\Users\testAdmin> (get-item "HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters").GetValue("HostName")hyperv01.intranet.kimconnect.com

Some Useful Windows Commands to Troubleshoot Networking on Windoze

# Check this computer's trust relationship to its domain controllers$domainName="intranet.kimconnect.com"PS C:\Windows\system32> nltest /SC_QUERY:$domainNameFlags: 0Trusted DC…

PowerShell: Quickly Start Services that were Set to Auto

Quick Liners: # Command to checkGet-WmiObject -ClassName Win32_Service -Filter "StartMode='Auto' AND State<>'Running'" | Format-Table -Auto…

PowerShell: Trigger Azure AD Sync on Remote Server as a Domain Admin

# Trigger-AD-Sync.ps1# Requirements: https://blog.kimconnect.com/powershell-install-rsat/## This script does these things:# a. Obtain Domain Admin credential# b.…

PowerShell: How to Logoff an User RDP Session

# logOffUser.ps1 $servername=$env:computername $userName='brucelee' function logOffRdpSession{ param( $serverName=$env:computername, $username ) $username=if($username -match '\\'){[regex]::match($username,'\\(.*)$').captures.groups.value[1] }else{ $username.tostring()…

PowerShell: How to Call a Batch File to Run-As Administrator

Step 1: Create a Batch File and place it inside C:\scripts @echo off powercfg.exe -x…

PowerShell: Manually Create Failover Cluster SMB Shares

# Set three variables$shareName="someShare"$smbServer="someClusteredVServer"$sharePath="S:\Shares\someShare"# Generate Domain Admins label$subdomain=(net config workstation) -match 'Workstation domain\s+\S+$' -replace '.+?(\S+)$','$1'$domainadmins="$subdomain`\Domain…

PowerShell: Grant Domain Admins Access to Directories

Snippet: # Messing around$shareDrives=@("E","F","G","I","J","N",'O','Q','R','S','T','U','V','W','Z','Y');$subdomain=(net config workstation) -match 'Workstation domain\s+\S+$' -replace '.+?(\S+)$','$1';$domainadmins="$subdomain`\Domain Admins"; $shareDrives | %{"Add-NTFSAccess…

PowerShell: Microsoft Clustered Disks Creation Script v 0.10

Code: <# Microsoft_Clustered_Disks_Creation_V0.10.ps1Purpose:This snippet streamlines the process of creating physical disk volumes on a Windows…

PowerShell: Deploy Certs on Remote Windows Servers

Quick Script for Local Machines: $certPath="C:\kimconnect_cert.pfx" $certPlaintextPassword='PASSWORD' $certEncryptedPassword=ConvertTo-SecureString $certPlaintextPassword -AsPlainText -Force Import-PfxCertificate -CertStoreLocation Cert:\LocalMachine\My -FilePath…

PowerShell: Microsoft Failover Cluster Discovery Version 0.10

<# .Sypnosis: Microsoft_Clusters_Discovery_v.0.10.ps1 What it does: - Installs Microsoft Failover Cluster PowerShell module on the…

PowerShell: Scheduled Task to Backup Local Files to remote UNC Path

Set Script Execution Policy on Host PS H:\> Set-ExecutionPolicy RemoteSignedExecution Policy ChangeThe execution policy helps…

PowerShell: Use EMCOPY to Mirror a Directory

# Purpose: this PowerShell snippet is to demonstrate the use of Emcopy$source="C:\Users\tester\Desktop\Clients"$destination="C:\Users\tester\Desktop\Test"#$switches="/o /secforce /s /de…

PowerShell: File Copying Operation

2/11/20 Update: Version 0.1.8 is available here: https://blog.kimconnect.com/powershell-file-copy-script-using-emcopy-vss-legacy/ Version 0.1.6 <#.Description File_Copy_Script Version: 0.16Purpose: this…

PowerShell: Convert Between Various SSL Certificate Formats

# Install Choco (look for instructions in this blog)# Install openssl.lightchoco install openssl.light -y #…

Renew or Replace a SSL Certificate in Dynamics CRM

Error Message: "Exchange Online Security Certificate Expiration Please update your certificate or Exchange Online integration…

Microsoft IIS: How to Forward from HTTP to HTTPS

1. Apply the URL Rewrite module as required:- https://www.iis.net/downloads/microsoft/url-rewrite- Extract and install it 2. Run…