DiD you know : You can find all values belonging to an ENUM in powershell

POSH TIP: List all values belonging to an ENUM in powershell

Enum is a value type available in .NET framework. Use GetNames static method of this class to list down all values belonging to and ENUM as shown below

[Enum]::GetNames([System.Management.Automation.ActionPreference])

In the above command System.Management.Automation.ActionPreference is the Enum whose values we are interested in..

The above code return a string array and it looks like below

    SilentlyContinue
    Stop
    Continue
    Inquire
    Ignore
    Suspend

The above code can be used with an .NET Enumeration type.

Another example are below..

[Enum]::GetNames([System.Windows.Forms.MessageBoxButtons])

    OK
    OKCancel
    AbortRetryIgnore
    YesNoCancel
    YesNo
    RetryCancel

Advertisements

DiD you know : You can find the class that implements a particular cmdlet

POSH TIP: Get .Net Class Name that implements a particular cmdlet

Use the Get-Command cmdlet along with the name of the target cmdlet for getting the implementing class like below..

(Get-Command -name Get-Process).ImplementingType.Name

Put the get-command along with name parameter within parenthesis and then use the ‘Name’ property of ‘ImplementingType’ property

The ImplementingType property returns the runtimeType object that actually contains the name of class implementing the cmdlet.

The output looks like below..GetProcessCommand is the class implementing the Get-Process cmdlet

GetProcessCommand

DiD you know : You can find the assembly that contains a particular cmdlet

POSH TIP: Find .Net assembly Name that implements a particular cmdlet

Use the Get-Command cmdlet along with the name of the target cmdlet for getting the implementing assembly like below..

(Get-Command -name Get-Process).DLL

Put the get-command along with name parameter within parenthesis and then use the ‘DLL’ property

The DLL property returns the assembly that actually contains the implementation of the cmdlet.

C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.PowerShell.Commands.Management\v4.0_3.0.0.0__31bf3856ad364e35
\Microsoft.PowerShell.Commands.Management.dll

DiD you know : You can find and list all Powershell alias

POSH TIP: Get all Powershell Alias

Use the Get-Alias cmdlet to find all alias available in Powershell console. Like below..

Get-Alias

And in case you want to find an particular alias, use the name parameter like below (write is one of the alias)

Get-Alias -name ‘write’

The name also accepts wildcards. If you want to find all alias starting with character ‘w’, use the name parameter like below

Get-Alias -name ‘w*’

SC Orchestrator Tip: How to copy a Runbook from one folder to another

Time and again, Orchestrator Runbook authors want to copy a runbook from one folder to another for a variety of reasons. The reasons could be folder hierarchy reorganization, want to use the same runbook functionality and add newer functionality but do not want to change the existing runbook- may be getting used already in other runbooks etc..

Orchestrator runbook designer does not have any feature out of the box to copy a runbook from one folder to another. If you right click on a runbook the following options are presented.

Options
Quite visible that the “Copy” option is not available. There are options to select the activities from within source runbook, copy them and then paste them on target runbook. This however, do not copy the runbook settings and configuration to the target runbook. The author still needs to manually update the target runbook with these settings and configuration.

An easy out-of-box way to copy runbook from one folder to another is available in Orchestrator however in a disguised manner. There is a great feature called Export and Import runbooks that can be used to copy a runbook.

Simply, export the source runbook and after exporting, import it to the target folder.

Hope you would find this tip helpful..