Category: Codes

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>…

PowerShell: Automating Process of Setting Up a New Windows Machine

# Step -2: Creating a New Virtual Machine # Example A: Hyper-V # Compulsory variables…

PowerShell: Activate Remote Windows

$remoteWindows="SHERVER01","SHERVER02"$licenseKey="XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"function activateWindows{ param( [string]$key ) $licensingService = get-wmiObject -query "select * from SoftwareLicensingService" -computername $env:computername;…

PowerShell: Execute as System Elevated Session with a Domain Administrator account

Part 1: Relaunch script in the context of Elevated System privileges: ############# Ensure that Program…

PowerShell: Update Windows Computers

There's a more updated version available. <# Update-Windows-Computers-v0.11.ps1 # # Purpose: trigger Microsoft Updates on…

PowerShell: Change IP of Remote Windows

# Change-IP-Remote-Windows.ps1$oldIP="192.168.40.135"$newIP="192.168.40.136"$netmask="255.255.255.0"$gateway="192.168.40.1"$dnsServers=@("10.10.8.1","10.10.18.1")function changeIpRemoteComputer{ Param ( [string]$oldIP, [string]$newIP, [string]$newSubnetMask = "255.255.255.0", [string]$newDefaultGateway, [array]$newDNS = @("8.8.8.8","4.4.2.2") )…

PowerShell: Kill Processes Remotely

# This function requires 2 parameters: -computerName and -processName function killRemoteProcess{ [cmdletbinding()] param( [string]$computerName=$env:COMPUTERNAME, [parameter(Mandatory=$true)]…

PowerShell: removing elements of an immutable “fixed size” array

By default, PowerShell's Array is an object class; hence, its length a "fixed size" as…

PowerShell: How To Bypass Double Hop Problems

# This is a working example of hoping without delegation. Fresh creds can be passed…

PowerShell: Reset Failover Clustering Quorum

# Adding Prerequisite Microsoft ClusterFunction installFailoverClustersModule{if (!(get-module -Name "FailoverClusters") ){#Install-WindowsFeature Failover-Clustering | out-null;Install-WindowsFeature RSAT-Clustering-MGMT |…

PowerShell: Create Daily VSS Snapshot of Volumes on Local Windows Machine

<# Daily-VSS-Snapshot-Windows-Standalone-FileServer.ps1 Functions: 1. Dynamically detect all volumes on local machine 2. Take snapshots of…

PowerShell: Windows Servers Systems Inventory

Version 0.03 <# Systems-Inventory.ps1Version: 0.03 -- deprecated 12/24/2019Purpose: to generate a CSV spreadsheet with information…

Changing SMB Caching on Windows

# To turn OFF caching $rolesWithNoCaching="SHERVER01","SHERVER02" $rolesWithNoCaching | %{$shares=Get-SMBShare -scopename "$_"; foreach ($share in $shares){if(!($share.Name…

Updating SSL Certificates on Active Directory Federation Services (ADFS) Server

Scripted Version Notes: Part 1: Adding Cert to ADFS Server # Import Cert and get…