November 2018
Intermediate to advanced
566 pages
17h 15m
English
There are two requirements here. We will add the functionalities to the same function, New-File.
Open a new file window, copy the contents of the 06-New-File.ps1 file, and make some changes so that the script looks like this:
function New-File {
[CmdletBinding(
ConfirmImpact='High',
SupportsShouldProcess=$true
)]
param (
# The path to the file (or the name)
[Parameter(Mandatory=$true, Position=0)]
[string[]]
$Path
)
begin {
Write-Host "$(Get-Date)"
}
process {
foreach ($Item in $Path) {
if ($PSCmdlet.ShouldProcess("$PsScriptRoot", "Create $Path")) {
New-Item -Path $Item -ItemType File
}
}
}
end {}
}
Run the script and call the function with three file-names as parameters. Dot-source the script; don't just call it. Alternatively, ...
Read now
Unlock full access