Quantcast
Channel: Coding - John Chapman
Viewing all articles
Browse latest Browse all 23

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

$
0
0

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.


Viewing all articles
Browse latest Browse all 23

Trending Articles