[PowerShell] Using Common Verbs for Custom PowerShell Cmdlets in C#

+1Share on TwitterShare on FacebookShare on LinkedInSubmit to StumbleUponhttp://d32vechvmk8aon.cloudfront.net/wp-content/uploads/2012/09/spjohnscreenshot.jpegDigg ThisSubmit to redditPin it on Pinterest

In my previous post, [PowerShell] Write a Custom PowerShell Cmdlet in C#, I mentioned that the commond verbs built-in to PowerShell should be used whenever possible.

using System;
using System.Management.Automation;

namespace MyPsCmdlet
{
    [Cmdlet(VerbsCommon.Get, "MyPsCmdlet")]
    public class MyPsCmdletGet : Cmdlet
    {

    }
}

Here is a listing of all of the common PowerShell verbs available in PowerShell 2.0:

  • VerbsCommon

    • Add
    • Clear
    • Close
    • Copy
    • Enter
    • Exit
    • Find
    • Format
    • Get
    • Hide
    • Join
    • Lock
    • Move
    • New
    • Open
    • Pop
    • Push
    • Redo
    • Remove
    • Rename
    • Reset
    • Search
    • Select
    • Set
    • Show
    • Skip
    • Split
    • Step
    • Switch
    • Undo
    • Unlock
    • Watch
  • VerbsCommunications

    • Connect
    • Disconnect
    • Read
    • Receive
    • Send
    • Write
  • VerbsData

    • Backup
    • Checkpoint
    • Compare
    • Compress
    • Convert
    • ConvertFrom
    • ConvertTo
    • Dismount
    • Edit
    • Expand
    • Export
    • Group
    • Import
    • Initialize
    • Limit
    • Merge
    • Mount
    • Out
    • Publish
    • Restore
    • Save
    • Sync
    • Unpublish
    • Update
  • VerbsDiagnostic

    • Debug
    • Measure
    • Ping
    • Repair
    • Resolve
    • Test
    • Trace
  • VerbsLifecycle

    • Approve
    • Assert
    • Complete
    • Confirm
    • Deny
    • Disable
    • Enable
    • Install
    • Invoke
    • Register
    • Request
    • Restart
    • Resume
    • Start
    • Stop
    • Submit
    • Suspend
    • Uninstall
    • Unregister
    • Wait
  • VerbsOther

    • Use
  • VerbsSecurity

    • Block
    • Grant
    • Protect
    • Revoke
    • Unblock
    • Unprotect

The list of available verbs is pretty extensive. There should be very few instances where one of these available verbs isn’t sufficient for your custom Cmdlets.

John Chapman

Hello, I'm John Chapman. I am a SharePoint Developer for NewsGator living in Denver, Colorado. I develop solutions using ASP.NET, C#, jQuery, SQL, SharePoint, etc, and I thrive on the challenge of writing code to overcome the impossible, annoying, or otherwise difficult obstacles.

More Posts - Website - Twitter - LinkedIn - Google Plus