Category: Codes

PowerShell: Invoke Backup SQL Database

Function to invoke SQL Backups on a Remote SQL Server: # invokeSqlBackup.ps1 # Version 0.0.1…

Windows: Force Dedicated RAM to Integrated Graphics

Please be advised that the following instructions will only be effective for Windows computers with…

PowerShell: Get SQL Server Performance Counters

Version 2 # getSqlPerformanceCounter.ps1 # version 0.02 $computername='sql0003.kimconnect.com' function getSqlPerformanceCounter($server=$env:computername,$sampleInterval=10,$maxSamples=1){ $PerformanceCounterSampleSet=$result=@() $counters=@( '\Memory\Available MBytes', '\Memory\Pages/sec',…

PowerShell: Use WinSCP to Test a SFTP Connection

# testSftpConnect.ps1 # Quick script to test SFTP connectivity $username='FTPUSER' $password='PASSWORD' $sftpServer='x.x.x.x' $sftpPort=22 function testSftpConnect($sftpServer,$username,$password,$sftpPort){…

PowerShell: Chicken Scratch Ports Scanner

Although there are optimized applications to perform this task such as Angry Port Scanner, NMAP,…

PowerShell: Setting Windows Pagefile

# setPageFile.ps1 # Source: # Reposting here as such code seems to be open source…

PowerShell: Optimize SQL Server Memory & CPU Resources

# optimizeSqlServer.ps1 # Version 0.0.2 # This version deals with Memory, CPU # Future versions…

Ubuntu/Lubuntu: Setting Up Development Environment

Linux is a great platform for development. One advantage of a this OS is that…

PowerShell: List All Hyper-V Snapshots of All VMs in All Clusters in Domain

# listHyperVSnapshots.ps1 $clusterName='*' function listAllHyperVSnapshots([string[]]$clusterName){ function includeRSAT{ $ErrorActionPreference='stop' [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 #$rsatWindows7x32='https://download.microsoft.com/download/4/F/7/4F71806A-1C56-4EF2-9B4F-9870C4CFD2EE/Windows6.1-KB958830-x86-RefreshPkg.msu' $rsatWindows7x64='https://download.microsoft.com/download/4/F/7/4F71806A-1C56-4EF2-9B4F-9870C4CFD2EE/Windows6.1-KB958830-x64-RefreshPkg.msu' $rsatWindows81='https://download.microsoft.com/download/1/8/E/18EA4843-C596-4542-9236-DE46F780806E/Windows8.1-KB2693643-x64.msu' $rsat1709…

PowerShell: Gather All Guess VM of All Hyper-V Clusters in the Domain

# getAllVms.ps1 $clusterName='*' function includeRSAT{ $ErrorActionPreference='stop' [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 #$rsatWindows7x32='https://download.microsoft.com/download/4/F/7/4F71806A-1C56-4EF2-9B4F-9870C4CFD2EE/Windows6.1-KB958830-x86-RefreshPkg.msu' $rsatWindows7x64='https://download.microsoft.com/download/4/F/7/4F71806A-1C56-4EF2-9B4F-9870C4CFD2EE/Windows6.1-KB958830-x64-RefreshPkg.msu' $rsatWindows81='https://download.microsoft.com/download/1/8/E/18EA4843-C596-4542-9236-DE46F780806E/Windows8.1-KB2693643-x64.msu' $rsat1709 = "https://download.microsoft.com/download/1/D/8/1D8B5022-5477-4B9A-8104-6A71FF9D98AB/WindowsTH-RSAT_WS_1709-x64.msu"…

PowerShell: Get All Hyper-V Servers in the Domain or Forest

This is a working version to correct my previous codes posted somewhere on this site…

Windows: Create a Quick Hot Spot From A Wired Computer with Spare Wireless Adapter

# Start the Hot Spot netsh wlan set hostednetwork mode=allow ssid="$env:username hotspot" key=whatpassword netsh wlan…

PowerShell: Remove Hyper-V VM Snapshots

Hyper-V's snapshot feature is a double-edged sword. It's a convenient method to make a quick…

PowerShell: Set Hyper-V Cluster Quorum

# setClusterQuorum.ps1 # version 0.01 $clustername=$null $clusterQuorum="\\FILESHERVER007\CLUSTER007" $resetPrior=$false function setClusterQuorum($clusterName,$clusterQuorum,$resetPrior=$false){ # Get clustername, if not…

PowerShell: Get Quorums of All Clusters in the Domain

# getClusterQuorum.ps1 function getClusterQuorum{ $allClusters=(get-cluster -domain $env:USERDNSDOMAIN).Name $results=@{} foreach ($cluster in $allClusters){ $quorum=Get-ClusterQuorum -Cluster $cluster…

PowerShell: Take VM Snapshots

# takeVmSnapshot.ps1 $vmNames='Test-VM1','Cowabunga-VM4' $snapShotLabel="Snapshot $(get-date -Format yyyyMMddTHHmmss)" function takeVmSnapshot([string[]]$vmName,[string]$snapshotLabel){ $vmClusterNodes=Get-ClusterGroup|?{$_.GroupType -eq 'VirtualMachine'} foreach ($vm in…

PowerShell: Disable Virtual Machine Queuing on Hyper-V Hosts

What is VMQ? Virtual Machine Queuing is a shortcut to deliver packet data from the…

PowerShell: Email Users with Expiring Passwords

# PasswordExpirationNotification.ps1 # Description: # This script performs the following tasks # a. Query Active…

PowerShell: Manage Remote Desktop Servers by Logging Off Idle Sessions That Have Certain Inactive Programs

# manageRdsSessions.ps1 # Sequence of workflow: # a. Gather active and disconnected sessions on all…

PowerShell: Find Duplicate RDP Sessions on All Remote Desktop Servers Discovered Within the Domain

There's this module called 'PSTerminalServices' that has a method to collect active sessions on all…