November 2018
Intermediate to advanced
566 pages
17h 15m
English
Parameter aliases are set when defining the parameters. Modify the script as follows to define the parameter aliases:
function Start-Count {
param (
# The current time, or the starting point
[Parameter(Mandatory=$false)]
[Alias("CT","From")]
[int]
$CurrentTime=0,
# The total number of seconds to count
[Parameter(Mandatory=$true, Position=1)]
[Alias("TT","To")]
[int]
$TotalTime
)
while ($CurrentTime -le $TotalTime) {
Write-Progress -Activity "Counting to $TotalTime" -Status "Counting: $CurrentTime seconds" -PercentComplete ($CurrentTime / $TotalTime * 100)
Start-Sleep 1
$CurrentTime++
}
}
Call the script:
PS> . ./ch12/02-Start-Count.ps1 PS> Start-Count -tt 7
Read now
Unlock full access