Skip to content

Instantly share code, notes, and snippets.

@jaymecd
Last active May 21, 2019 22:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaymecd/18330f021c58d1aba07fbcd7aad1a22e to your computer and use it in GitHub Desktop.
Save jaymecd/18330f021c58d1aba07fbcd7aad1a22e to your computer and use it in GitHub Desktop.
measure command time
function time([scriptblock]$scriptblock) {
$sw = [Diagnostics.Stopwatch]::StartNew()
. $scriptblock
$sw.Stop()
Write-Output ""
Write-Output " >> Execution time: $($sw.Elapsed)"
}
time { Install-Module -Name PSWindowsUpdate }
$categories = 'Critical Update','Security Update','Definition Update','Service Pack','Update Rollup'
time { Get-WUInstall -Install -Category $categories -Verbose -AcceptAll -IgnoreReboot }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment