November 2018
Intermediate to advanced
566 pages
17h 15m
English
We will use the same script that we did in the Defining parameters recipe, with two small changes in it. Create a PowerShell script file with the following content:
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=$false, Position=1)]
[Alias("TT", "To")]
[int]
$TotalTime=10
)
while ($CurrentTime -le $TotalTime) {
Write-Progress -Activity "Counting to $TotalTime" -Status "Counting: $CurrentTime seconds" -PercentComplete ($CurrentTime / $TotalTime * 100)
Start-Sleep 1
$CurrentTime++
}
}
At the terminal, dot-source and run the script. Call the function without passing any ...
Read now
Unlock full access