0

I have a powershell script where I want to be able to bring up a help screen. So far it accepts 3 parameters directoryURL loginprefix and validateOnly.

param( [Parameter(Mandatory=$true)] [string]$directoryUrl, #[Parameter(Mandatory=$true)] [string]$prependedPermissions, #[Parameter(Mandatory=$true)] [string]$validateOnly ); 

What I want to check if someone types -help in the argument anywhere such as .\scriptName.ps1 -help it will be able to appear on the screen.

How can I do that?

1

1 Answer 1

1

This is propably not the way to go.

Powershell have very nice documentation features build in. If you add the following documentation comments in the top of your script, you will be able to just type help myscript.ps1 to get the help output.

<# .SYNOPSIS Short description of this scripts purpose .PARAMETER directoryUrl The URL to the directory .PARAMETER prependedPermissions Prepended permissions .PARAMETER validateOnly Only validate #> param( [Parameter(Mandatory=$true)] [string]$directoryUrl, #[Parameter(Mandatory=$true)] [string]$prependedPermissions, #[Parameter(Mandatory=$true)] [string]$validateOnly ); 

You can find more information on the documentation feature in the following article https://technet.microsoft.com/en-us/magazine/hh500719.aspx

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.