November 2018
Intermediate to advanced
566 pages
17h 15m
English
We will only write the first function; we already have a function to create the files. Follow these steps to get started:
function New-FileName {
param (
# The name of the file
[Parameter(Mandatory=$false)]
[string]
$Prefix='File',
# The number of files to be generated
[Parameter(Mandatory=$false, Position=1)]
[int]
$Count=1
)
begin {
$InitCount = 1
}
process {
while ($InitCount -le $Count) {
Write-Output $Prefix$InitCount
$InitCount++
}
}
}
Copy and paste the New-File function from 09-New-File.ps1. You may want to remove the ConfirmPreference line from the function if you do not want the function to prompt you to confirm the ...
Read now
Unlock full access