home *** CD-ROM | disk | FTP | other *** search
- TOPIC
- Scrpt Cmdlet Attributes
-
- SHORT DESCRIPTION
- Attributes available to script cmdlets that define functionality.
-
- LONG DESCRIPTION
- When writing script cmdlets, you can add attributes to the cmdlet
- declaration that specify functionality that is common between
- cmdlets.
-
- NOTE: Compiled cmdlets use a CmdletAttribute attribute that is similar
- to the attributes described here. In fact, several of these attributes are
- optional parameters of the CmdletAttribute attribute.
-
- The following example shows the outline of a script cmdlet with all the
- cmdlet attributes specified. Following this example is a brief
- description of each attribute.
-
- Cmdlet Verb-Noun
- -SupportsShouldProcess
- -DefaultParameterSet MyParameterSet
- -ConfirmImpact low
- -snapin MySnapin
-
- {
- Param ([Mandatory] $Parameter1)
- Begin{}
- Process{}
- End{}
- }
-
-
- -SuppotsShouldProcess
- This attribute indicates that the cmdlet supports calls to the
- ShouldProcess method, which provides the cmdlet with a way to prompt the
- user for feedback before an action that changes the system is performed.
- When this attribute is specified, the -confirm and -whatif parameters
- are enabled for the cmdlet.
-
- For more information about confirmation requests, see Requesting
- Confirmation in the Windows PowerShell Programmer's Guide on MSDN.
-
-
- -DefaultParameterSet name
- This attribute specifies the name of the parameter set that the Windows
- PowerShell runtime attempts to use when it cannot determine which
- parameter set to use. Notice that this situation can be eliminated by
- making the unique parameter of each parameter set a mandatory parameter.
-
-
- -ConfirmImpact setting
- This attribute specifies when the action of the cmdlet should be
- confirmed by a call to the ShouldProcess method. ShouldProcess will
- be called only when the setting parameter of -ConfirmImpact (by default
- Medium) is equal to, or greater than, the value of the
- $ConfirmPreference variable. This attribute should be specified only when
- the -SupportsShouldProcess attribute is specified.
-
- -snapin SnapinName
- This attribute specifies the name of the snap-in that is used to
- register the cmdlet and remove it from the shell. Notice that for
- compiled cmdlets, the snap-in module typically contains the cmdlet
- class.
-
-
-
- SEE ALSO
-
- About_ScriptCmdlets
- About_ScriptCmdletParameters
- About_ScriptCmdletMethods