Month: October 2019

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: 1-liner to obtain SSID and Password of Wireless Profiles on a Windows Machine

$profileName='Frontier0000'netsh wlan show profile "name=$profileName" key=clear|select-string "Key Content"# Sample outputKey Content : somepassword PS C:\Windows\system32>…

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…