wiki.getshifting.com

--- Sjoerd Hooft's InFormation Technology ---

User Tools

Site Tools


cheatsheet-powershell
Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
cheatsheet-powershell [2025/10/26 19:52] sjoerdcheatsheet-powershell [2025/11/19 20:07] (current) sjoerd
Line 107: Line 107:
 [datetime]$endDate = (Get-Date).AddDays(+90) [datetime]$endDate = (Get-Date).AddDays(+90)
 [datetime]$endDate = (Get-Date).AddDays(-90) [datetime]$endDate = (Get-Date).AddDays(-90)
 +</code>
 +
 +== PowerShell Measure Command Time ==
 +
 +Sometimes it's useful to measure how long a command takes. I create the snippet below to measure the amount of time a Test-NetConnection commando took and used it to replicate a sort of ping utility.
 +
 +<code powershell>
 +$counter = 0
 +while ($true){
 +  $timer = [Diagnostics.Stopwatch]::StartNew()
 +  Test-NetConnection kv-shift-001.privatelink.vaultcore.azure.net -port 443 -InformationLevel Quiet
 +  $timer.Stop()
 +  $elapsed = $timer.elapsed
 +  $counter ++
 +  Write-Host "Counter: $counter; in $elapsed seconds"
 +  Sleep 1
 +}
 </code> </code>
  
cheatsheet-powershell.txt · Last modified: by sjoerd