Author: kimconnect

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…

PowerShell: How to Change Guest VM Names in Virtual Machine Manager

# changeGuessVmNameInVmm.ps1 # The following script prepend all VM's matching certain pattern # This is…

Resume All Guest VMs in a Clustered Hyper-V Environment

# resumeAllVms.ps1 # Significance: this script is useful in a Clustered Hyper-V environment # where…

PowerShell: Command to Retrieve Windows Applications List

The following the the PoSH equivalent of appwiz.cpl in Windows: PS> invoke-command TestWindows {Get-Package -Provider…

Linux Cheat Sheet

Below is a quick reference to the most useful commands and techniques for a Linux…

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…

How to Set PowerShell Window and Prompt Title or Label

Have you ever wondered about changing the boring PS C:\Windows\system32> whenever a new window is…

Use DISM To Install Windows Features

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

How To Delete Virtual Machine in Unsupported Configuration Status

Possible Errors in VMM Console: Error (20408)VMM could not get the specified instance Msvm_VirtualSystemSettingData.InstanceID="Microsoft:1D78A299-C989-40FC-BC5C-B54934A126B7" of…

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 Upgrade Kubernetes Ingress Nginx Deployed via Helm

# How to upgrade ingress-nginx: helm upgrade --reuse-values ingress-nginx ingress-nginx/ingress-nginx -n ingress-nginx # Sample output of a failure scenario: brucelee@k8-controller:~$ helm…