What are good guidelines for naming PowerShell verbs?

大兔子大兔子 提交于 2019-12-04 09:09:57

You can find a list of common verbs on MSDN along with a description what they should be used for.

Here's an updated list of approved verbs on the Windows PowerShell Blog, as of July 15.

From your use of the word "modules", I'm going to guess you are using V2 of PowerShell, which allows you to take advantage of Advanced Functions.

Advanced functions provide a way to attribute your function to provide native support for -WhatIf and -Confirm

function Sync-PerforceRepository()
{
  [cmdletbinding(SupportShouldProcess=$true)]
  param (...) #add your parameters
  Begin
  {
    #setup code here
  }
  Process
  {
    if ($pscmdlet.ShouldProcess($ObjectBeingProcessed,"String Describing Action Happening")
    {
      #Process logic here
    }
  }
  End
  {
     #Cleanup code
  }

}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!