home *** CD-ROM | disk | FTP | other *** search
/ Chip 2008 June / CHIP-2008-06.iso / software / PowerShell / PowerShell_Setup_x86.msi / product.cab / about_scriptcmdletattributes.help_EN.txt < prev    next >
Encoding:
Text File  |  2007-10-29  |  2.4 KB  |  72 lines

  1. TOPIC
  2. Scrpt Cmdlet Attributes
  3.  
  4. SHORT DESCRIPTION
  5. Attributes available to script cmdlets that define functionality.
  6.  
  7. LONG DESCRIPTION
  8. When writing script cmdlets, you can add attributes to the cmdlet 
  9. declaration that specify functionality that is common between 
  10. cmdlets.
  11.  
  12. NOTE: Compiled cmdlets use a CmdletAttribute attribute that is similar 
  13. to the attributes described here. In fact, several of these attributes are 
  14. optional parameters of the CmdletAttribute attribute.   
  15.  
  16. The following example shows the outline of a script cmdlet with all the 
  17. cmdlet attributes specified. Following this example is a brief 
  18. description of each attribute.
  19.  
  20. Cmdlet Verb-Noun
  21.   -SupportsShouldProcess
  22.   -DefaultParameterSet MyParameterSet
  23.   -ConfirmImpact low
  24.   -snapin MySnapin
  25.  
  26.   {
  27.     Param ([Mandatory] $Parameter1)
  28.     Begin{}
  29.     Process{}
  30.     End{}
  31.   }
  32.  
  33.  
  34. -SuppotsShouldProcess
  35. This attribute indicates that the cmdlet supports calls to the 
  36. ShouldProcess method, which provides the cmdlet with a way to prompt the 
  37. user for feedback before an action that changes the system is performed. 
  38. When this attribute is specified, the -confirm and -whatif parameters 
  39. are enabled for the cmdlet.  
  40.  
  41. For more information about confirmation requests, see Requesting 
  42. Confirmation in the Windows PowerShell Programmer's Guide on MSDN.
  43.  
  44.  
  45. -DefaultParameterSet name
  46. This attribute specifies the name of the parameter set that the Windows 
  47. PowerShell runtime attempts to use when it cannot determine which 
  48. parameter set to use. Notice that this situation can be eliminated by 
  49. making the unique parameter of each parameter set a mandatory parameter.
  50.  
  51.  
  52. -ConfirmImpact setting
  53. This attribute specifies when the action of the cmdlet should be 
  54. confirmed by a call to the ShouldProcess method. ShouldProcess will 
  55. be called only when the setting parameter of -ConfirmImpact (by default 
  56. Medium) is equal to, or greater than, the value of the 
  57. $ConfirmPreference variable. This attribute should be specified only when 
  58. the -SupportsShouldProcess attribute is specified.
  59.  
  60. -snapin SnapinName
  61. This attribute specifies the name of the snap-in that is used to 
  62. register the cmdlet and remove it from the shell. Notice that for 
  63. compiled cmdlets, the snap-in module typically contains the cmdlet 
  64. class. 
  65.  
  66.  
  67.  
  68. SEE ALSO
  69.  
  70. About_ScriptCmdlets
  71. About_ScriptCmdletParameters
  72. About_ScriptCmdletMethods