Owlglass

PowerShell - Writing cmdlets in C#

Writing powershell cmdlets in C#

source: dotnetninja

Overview

create a new class that derives from one of two base classes (Cmdlet or PsCmdlet), add properties to the class to accept your parameters, override one or more methods in the base class to provide your functionality, and decorate the class and properties with a few attributes.

cmdlet name

all defined in constants in the C# reference library

VerbsCommon: Add, Clear, Close, Copy, Enter, Exit, Find, Format, Get, Hide, Join, Lock, Move, New, Open, Optimize, Pop, Push, Redo, Remove, Rename, Reset, Resize, 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