Category: Codes

Fiddler: A HTTPS Debugging Tool

An application support specialist would find this tool useful to intercept HTTPS traffic on a…

How To Link Containers Using Docker Compose

This yields several advantages:1. Direct linking between containers is architectually efficient to direct traffic between…

PowerShell: Maintain Windows Services Remotely via WinRM

# maintainServices.ps1 # FQDN of each computer name (required) $computerList=@' testWindows.intranet.kimconnect.com testWindows.dmz.dragoncoin.com '@ $serviceNames=@( 'windows_exporter',…

PowerShell: Kill a Windows Service Forcefully

# killService.ps1 $serviceName='vmms' function killService($serviceName='Spooler',$restart=$false){ $processId=Get-WmiObject -Class Win32_Service -Filter "Name LIKE '$serviceName'"|Select-Object -ExpandProperty ProcessId if($processId.count…

How to Install PowerShell Module on An Offlined Computer

# Download the desired module onto a 'jump host' (an intermediary computer that has access…

PowerShell: Uninstall Program Using Its Name

# uninstallProgramUsingId.ps1 $appName='Virtual Machine Manager Agent' $uninstallStringRegPaths='HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall','HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall' $uninstallStrings=Get-ChildItem -Path $uninstallStringRegPaths $uninstallString=($uninstallStrings|Get-ItemProperty|Where-Object {$_.DisplayName -match $appName}).UninstallString if($uninstallString.count…

PowerShell: Get Connected Port by Process Name

# getProcessConnectionPort.ps1 $computerlist=@' SQL1 SQL2 '@ $computernames=@($computerList -split "`n")|%{$_.Trim()} $processname='sqlservr' $state='Established' $results=@() foreach ($computername in…

PowerShell: Quickly Test Connectivity from a List of Sources toward a Destination on a Specific Port

# testRemotePort.ps1 $connectFrom=@' windows1 windows2 '@ $connectTo=@' \\servername\sharename '@ $testPort=445 $sources=@($connectFrom -split "`n")|%{$_.Trim()} $destinations=@($connectTo -split…

How To Recover SQLSERVER Service from Being Unable to Start

# startSqlService.ps1 # special provision to deal with SQL Server not starting up due to…

How to Search for Installed Application by Name in PowerShell

One can search using the known Vendor or application Name as illustrated below: [testwindows]: PS…

PowerShell: Create Registry Keys within Windows Localhost

# createRegKey.ps1 $regKeys=@( @{ hive='REGISTRY::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome'; name='ChromeCleanupEnabled'; value=0 } @{ hive='REGISTRY::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome'; name='ChromeCleanupReportingEnabled'; value=0 } ) function…

Windows: How to Map Network Drive for All Users of a Local Machine

# Mapping file share using legacy commands (more effective than newer PowerShell equivalents in certain…

Use DISM To Install Windows Features

Deployment Image Servicing and Management (DISM.exe) is a command-line tool that can be used to…

Upgrade Virtual Hardware Version in VMM

The following script will upgrade all guest virtual machines from a lower version to the…

PowerShell: Get Available RAM Slots

# getRamSlotsAvailable.ps1 $computername=$env:computername function getRamSlotsAvailable{ param($computername=$env:computername) write-host "Computer name: $computerName" $slots = Get-WmiObject -Class "win32_PhysicalMemoryArray"…

Use PowerShell to Get GeoLocation of a Computer’s Public IP

Method 1: Invoke-RestMethod -Uri ('http://ipinfo.io/'+(Invoke-WebRequest -uri "http://ifconfig.me/ip").Content) Method 2: function getIPGeolocation($ipAddress) {$request = Invoke-RestMethod -Method…

How To Add or Remove a Path in Windows Environmental Paths

There are 2 functions to Add and Remove, at your convenience: # addEnvironmentalPath.ps1 $pathToAdd='C:\Scripts' $pathToRemove='C:\Scripts'…

PowerShell: Find Windows RDS Roles and Their Licensing Servers

# Get TS Licensing Servers (Enterprise or AD Registered) $termLicenseServers=Get-ADGroupMember -Identity "Terminal Server License Servers"…

PowerShell: Install App Using MSI on Remote Computers Via WinRM

# installMSiRemoteComputers.ps1 # version 0.0.1 $computernames='REMOTEPC001','REMOTEPC002' $thisMsiFile='C:\Temp\something.msi' $appName='testapp' $desiredVersion='1.0' $maxWaitSeconds=120 function installMsiOnRemoteComputers($computernames,$msiFile,$appName,$desiredVersion,$maxWaitSeconds){ function installMsiOnRemoteComputer{ param(…

PowerShell: Move Guest VM to Different Cluster in Hyper-V

# Assumptions: # - Guest VM files are stored at a single location # -…