Difference between revisions of "PowerShell Template"

From TekiWiki
Jump to: navigation, search
(Created page with "The following is a PowerShell template, showing parameters and scripting:")
 
 
Line 1: Line 1:
 
The following is a [[PowerShell]] template, showing parameters and scripting:
 
The following is a [[PowerShell]] template, showing parameters and scripting:
 +
 +
<pre>
 +
<#
 +
.SYNOPSIS
 +
One line description
 +
 +
.DESCRIPTION
 +
Long description of the script.
 +
 +
.EXAMPLE
 +
args.ps1 -name "Xyz" -Path "xyz"
 +
 +
.INPUTS
 +
Input stuff
 +
 +
.OUTPUTS
 +
Output Stuff
 +
 +
.NOTES
 +
Notes section
 +
 +
.LINK
 +
http://www.homemarketeer.com
 +
 +
#>
 +
 +
param(
 +
 +
## Help for File name parameter
 +
## Put the name of the file in this parameter
 +
[string] $Name,
 +
## Help for Path name parameter
 +
[string] $Path
 +
)
 +
 +
## Display Info
 +
"Path  " + $PSCommandPath
 +
"Loc  " + $PSScriptRoot
 +
"Command " + $myInvocation.Line
 +
 +
## Display arguments
 +
 +
"Name  $Name"
 +
"Path  $Path"
 +
"============================================"
 +
 +
"args[0]  " + $args[0]
 +
"args[1]  " + $args[1]
 +
 +
$args
 +
 +
$args.length
 +
 +
</pre>

Latest revision as of 18:48, 24 June 2018

The following is a PowerShell template, showing parameters and scripting:

<#
.SYNOPSIS
One line description

.DESCRIPTION
Long description of the script.

.EXAMPLE
args.ps1 -name "Xyz" -Path "xyz"

.INPUTS
Input stuff

.OUTPUTS
Output Stuff

.NOTES
Notes section

.LINK
http://www.homemarketeer.com

#>

param(

	## Help for File name parameter
	## Put the name of the file in this parameter
	[string] $Name,
	## Help for Path name parameter
	[string] $Path
)

## Display Info
"Path  " + $PSCommandPath
"Loc   " + $PSScriptRoot
"Command " + $myInvocation.Line

## Display arguments

"Name  $Name"
"Path  $Path"
"============================================"

"args[0]  " + $args[0]
"args[1]  " + $args[1]

$args

$args.length