Building PoshCAT Part 2 – Adding your own custom functions

Last week I showed how you can create different Client Actions lists for different support groups in your organization and in this post I will show how you can add/create your own custom functions for PoshCAT

So let’s assume that you would like to query applied Computer Group Policy objects. If you want that your custom function returns some kind of information, then it must return PSObject.

Here is the function that I use in this example. This function queries only applied/enabled policies

This function creates the following output

GPO_custom_Function_output

To add this function to PoshCAT

1. Open WorkerFunctions.ps1 file with PowerShell ISE and copy the Get-ComputerAppliedPolicies function to custom functions section

clip_image005

2. Save the WorkerFunctions.ps1 file

3. Open Commands.XML file and add the following line

GPO_custom_Function_XML

4. Save the Commands.XML file

5. Start PoshCAT

If you have followed all the steps correctly you should see the command in PoshCAT

clip_image008

This custom function creates following output

PoshCAT_Custom_Action_output

Enjoy!

About the Author:

Kaido Järvemets
Configuration Manager MVP

2 Comments

  1. Naga Sai Jonnavithula November 4, 2015 at 6:49 - Reply

    Thanks a lot for the wonderful tool and the documentation. Is there a way I can provide a list of machines to remove from a collection ? (only from the collection).

    Thanks much.

  2. Diana August 8, 2017 at 18:28 - Reply

    How can I change this script, so that when I pull in a collection from sccm it will translate computer name to fqdn?

Leave A Comment