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 / 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 / test.html
Created November 7, 2015 09:14
leaks memory. why?
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
<title>Testmess on win10-dev</title>
<style type="text/css">
body {
font: 16px Courier New, monospace;
line-height: 15px;
padding: 2em 3em;
function Get-UpdateList {
<#
.SYNOPSIS
Gets an ISearchResult containing updates from Windows Update.
.PARAMETER Computername
The target computer.
Cannot use an array of computernames here.
Defaults to the local PC.