Month: March 2022

PowerShell: Add Network Sites (VLAN) into a Virtual Machine Manager Logical Network

# addVmmNetworkSites.ps1 # version 0.01 # User Defined Variables $networkSites=@( @{ 'newNetworkSitename'="test 1" 'vlanId'=100 'vlanCidr'='192.168.1.0/24'…

Virtual Machine Networking Error 15011

Creating New Logical Network $logicalNetworkID="somehash-hash-hash" $newNetworkName='Test Network' $subnet="192.168.500.0/24" $logicalNetwork = Get-SCLogicalNetwork -ID $logicalNetworkID $vmNetwork =…

PowerShell: Automatically Fix SQL Server by Killing Long Running Queries

# autofixSqlLongRunningQueries.ps1 # version 0.01 # This version is limited to SQL Server Localhost execution,…

PowerShell: Add RDS Server Role

Step 0: Searching for RDS Licensing Server # Get TS Licensing Servers $termLicenseServers=Get-ADGroupMember -Identity "Terminal…

PowerShell: Unlimit RDP Sessions

$tsRegHive='REGISTRY::HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server' Set-ItemProperty -Path $tsRegHive -Name fSingleSessionPerUser -value 0 Set-ItemProperty -Path $tsRegHive -Name fdenyTSConnections -value…

PowerShell: Install Windows Exporter

Simple Version $windowsExporterUrl='https://github.com/prometheus-community/windows_exporter/releases/download/v0.20.0/windows_exporter-0.20.0-amd64.msi' $stageFolder='C:\Temp\' # Download the file Import-Module BitsTransfer $fileName=[regex]::match($windowsExporterUrl,'[^/\\&\?]+\.\w{3,4}(?=([\?&].*$|$))') $msiFile=join-path $stageFolder $fileName if(!(test-path…

PowerShell: Check Whether an Application Is Installed Using Known Service Name

# Check whether product is installed $serviceName='windows_exporter' function checkUninstall($serviceName){ $cpuArchitecture32bitPointerSize=4 $path=if ([IntPtr]::Size -eq $cpuArchitecture32bitPointerSize) {…

PowerShell: Download and Apply Windows Patch KB

The following snippet assumes that a Windows machine has access to download Microsoft patches directly…

PowerShell: Downloading File Error ‘Internet Explorer engine is not available’

Error Message: PS C:\temp> wget http://download.windowsupdate.com/d/msdownload/update/software/secu/2022/01/windows10.0-kb5009546-x64_d3ab97e9f811d7bf19c268e5e6b5e00e92e110ed.msu wget : The response content cannot be parsed because…

PowerShell: Search File Contents Matching a Phrase or String

$searchDirectories='C:\users\Public\.jenkins\jobs' $searchDepth=1 $fileNameScope='*.xml' $searchString='kimconnect' # Select the files and perform the search in each file…