Kommentar
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
In my previous posts I used "-AsJob" parameter to determine if function will be called as a background Powershell job or not. I declared "$AsJob" object as [bool] so one should type explicitly "-AsJob $true" or "-AsJob $false" to make it run. I was trying to figure out a way to get rid of unnecessary $true/$false typings and I encountered with the sites in references. So I learnt what I was searching for; it's called "switch parameter"
For example "Test-FileSizeUntil" function had the following parameter declaration; $AsJob is [bool] -> BAD IDEA :)
[Parameter(mandatory=$false)]
[bool]$AsJob=$false
it should be:
[Parameter(mandatory=$false)]
[switch]$AsJob
Check the references for more info..
Reference#1: https://devcentral.f5.com/weblogs/Joe/archive/2009/01/13/powershell-abcs---p-is-for-parameters.aspx
Reference#2: https://msgoodies.blogspot.com/2006/12/negating-powershell-switch-parameters.html
Cheers, CanD