Menu

[ea00bd]: / ps-usage / PS-DebugHeader.ps1  Maximize  Restore  History

Download this file

26 lines (25 with data), 562 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#
# an example of how to add a -d (debug) switch to a command line, and allow
# Write-Debug output to be seen on console... -pat
#
[CmdletBinding()]
param(
[Alias("URL")] # case INsensitive
[string]$theURL = "http://somewhere/this/thing.xyz",
[string]$someFile = "./foo.txt",
[string]$anotherFile = "./bar.txt",
[switch]$d # debug output to console
)
#
# is the dbug switch on?
#
# use: ThisFile.ps1 [...] -d
#
if ($d) {
$DebugPreference = 'Continue'
} else {
$DebugPreference = 'SilentlyContinue'
}
#
# [...]
#
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.