From a5a5fe2138edfaaa8a64dda7dc793dd8ca98b3fe Mon Sep 17 00:00:00 2001 From: lub Date: Wed, 18 Jan 2023 11:06:50 +0100 Subject: [PATCH] implement watch function in profile.ps1 --- profile.ps1 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/profile.ps1 b/profile.ps1 index 5349b23..8d0d4a2 100644 --- a/profile.ps1 +++ b/profile.ps1 @@ -91,6 +91,22 @@ function fsh { Enter-PSSession @PSBoundParameters @args } +function watch { + param ( + [int]$n = 2, + + [Parameter(Mandatory, + Position = 0)] + $ScriptBlock + ) + + while ($true) { + $o = Invoke-Command -ScriptBlock $ScriptBlock + Clear-Host + $o + Start-Sleep -Seconds $n + } +} #check for old version if($PSVersionTable.PSVersion.Major -le 5){