Skip to content

Instantly share code, notes, and snippets.

function Get-DownloadSpeed
{
[CmdletBinding()]
Param
(
# Param1 help description
[Parameter(Mandatory=$true, Position=0)]
$SpeedtestServer,
@bklockwood
bklockwood / gist:64c171ece8b6a61fbb82
Last active August 29, 2015 14:21
Return disk space and freespace as GB, rounded to 2 decimal places, in powershell
PS> Get-CimInstance win32_logicaldisk | foreach-object {write "$($_.caption) $([math]::round(($_.size /1gb),2)), $([math]::round(($_.FreeSpace /1gb),2)) "}
C: 117.99, 21.12
D: 59.45, 9.48
E: 0, 0
F: 1863.02, 830.57
G: 7.6, 0.22
Y: 1862.89, 1409.86
@bklockwood
bklockwood / gist:6ac946e92e90e68384cc
Last active August 29, 2015 14:21
Collect Windows install info (simple)
#replace get-ciminstance with get-wmiobject if using v2
Get-CimInstance win32_operatingsystem | ft -autosize `
CSName, `
Caption, `
OSArchitecture, `
@{Label="RAM, GB"; Expression={[math]::round($_.TotalVisibleMemorySize/1mb, 2)}}
Get-CimInstance win32_processor | ft -autosize `
@{Label="Socket"; Expression={$_.SocketDesignation}}, `
@bklockwood
bklockwood / Windows10-Setup.ps1
Last active August 29, 2015 14:27 — forked from NickCraver/Windows10-Setup.ps1
(In Progress) PowerShell Script I use to customize my machines in the same way for privacy, search, UI, etc.
##################
# Privacy Settings
##################
# Privacy: Let apps use my advertising ID: Disable
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 0
# To Restore:
#Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 1
# Privacy: SmartScreen Filter for Store Apps: Disable
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost -Name EnableWebContentEvaluation -Type DWord -Value 0
@bklockwood
bklockwood / gist:13f6b17eb98e8f4b0a95
Created September 4, 2015 10:53
Get-Temperature
function Get-Temperature {
$t = Get-WmiObject MSAcpi_ThermalZoneTemperature -Namespace "root/wmi"
$returntemp = @()
foreach ($temp in $t.CurrentTemperature)
{
$currentTempKelvin = $temp / 10
$currentTempCelsius = $currentTempKelvin - 273.15
$currentTempFahrenheit = (9/5) * $currentTempCelsius + 32
$returntemp += $currentTempCelsius.ToString() + " C / " + $currentTempFahrenheit.ToString() + " F / " + $currentTempKelvin + "K"
@bklockwood
bklockwood / gist:fa950b74c5b97d0adc3e
Last active September 5, 2015 08:33
Powershell CPU exerciser
$i=1; while ($i -lt 200) {write-warning "iteration $i completed in $(Measure-Command {$result = 1; foreach ($number in 5000..1000000) {$result = $result * $number}})"; $i++}
@bklockwood
bklockwood / offlinewucheck.ps1
Last active March 3, 2022 04:05
Powershell offline WU check
<#
This script performs the 'search' phase of a Windows Update, using the standard WUA API.
It does not download or install updates.
Sole purpose of this script is to find out how long it takes to download the required cabfile,
then process it against a live system and return the list of updates available for that system.
#>
function DownloadFile {
param (
[Parameter(Mandatory=$true,Position=0)] $url,
[Parameter(Mandatory=$true,Position=1)] $file
@bklockwood
bklockwood / where.ps1
Last active October 22, 2015 04:27
multiple WHERE criteria
start-process notepad; start-process calc; start-process wordpad
start-process notepad; start-process calc; start-process wordpad
#now the part I always forget
get-process | where processname -in notepad,calc,wordpad
#spaces ok too
get-process | where processname -in notepad, calc, wordpad
@bklockwood
bklockwood / switch-compare-op.ps1
Created October 22, 2015 20:05
comparison operator in switch statement
$size = $(get-item .\Rootstore.sst).Length
Write-Host "Size $size"
switch ($size) {
($_ -gt 30000000000) {$foo = "reallybig" ;break}
($_ -lt 25000000000) {$foo = "size5" ;break}
($_ -lt 20000000000) {$foo = "size4" ;break}
($_ -lt 15000000000) {$foo = "size3" ;break}
($_ -lt 10000000000) {$foo = "size2" ;break}
($_ -lt 5000000000) {$foo = "size1" ;break}
}
@bklockwood
bklockwood / simplepswu.ps1
Last active November 6, 2017 19:07
Simplified PSWU
#requires -version 2.0
function Get-UpdateList {
<#
.Synopsis
Gets list of updates from Windows Update.
.PARAMETER Criteria
The search criteria, see http://goo.gl/7nZSPs