Pages

Monday, February 6, 2012

PowerOfTheShell(How To)

Download Zip and extract.
PowerOfTheShell Plugin is very easy to get started with.
Just copy/extract the content of the zip to the destination you want.


Open PC Monitor Manager and add the plugin.






Open plugin config.xml in your favorite editor and create your menu structure.






Short explanation of the XML.
<main> Start Tag
<group> Start the XML with a group before creating all pages and subpages below,


·         title : group name (e.g PowerOfTheShell).


·         enabled: set to True/False shows/hides the whole group.


·         maxResults: limit the amount of results the scripts can return.


<page> A new page,


·         title: page name (e.g Antivirus).


·         pageId: numeric value.(never assign value 0 or the same value twice)


·         subtitle: subtitle text: (e.g Tools for Antivirus).


·         enabled: set to True/False shows/hides the page.


<subpage> A new subpage,


·         title: subpage name (e.g Information).


·         pageId: numeric value.(never assign value 0 or the same value twice)


·         subtitle: subtitle text: (e.g retrieve vendor and status).


·         enabled: set to True/False shows/hides the subpage.


<command> A new command,


·         title: command title (e.g Run script)


·         commandId: numeric value.(never assign value 0 or the same value twice)


·         path: Where your script lies(e.g D:\Scripts\antivirus.ps1)


·         arguments: if your script takes arguments then can be applied here.


</subpage> Closing Subpage
</page> Closing Page


</group> Closing Group
</main> End Tag.

Allow execution of scripts.

Before starting to test the menu and scripts. We need to allow the execution of the scripts.
PowerShell comes default with the ExecutionPolicy: Restricted to allow the plugin to work we need to set the execution policy to RemoteSigned  or Unrestricted(First choice is more secure and recommended)
Open PowerShell, Needs to be elevated because the settings are altered in the Registry.
Run the Get-ExecutionPolicy command to get current setting.
Change the setting by running Set-ExecutionPolicy RemoteSigned, click "y" when promted. The policy is now changed to RemoteSigned.








Simple script Example.
Please note that when running your script(s) in PCM you cannot use cmdlets like write-host or other output formats, this will not work! Instead just list the variable like this.

$info = get-wmiobject -namespace "root/SecurityCenter2" -Query "Select * from AntivirusProduct"
if(($info.productstate -eq 266240) -or ($info.productstate -eq 262144))
{
 $info.displayName
 "Status: OK"
}
else
{
 $info.displayName
 "Status: NOT Updated"
}

1 comment:

  1. Hi Johnni,

    I like the functionality that this brings to PC Monitor. I tried it last night, but the results don't display after I hit "Run Script". Am I looking in the wrong place. I am using IE.

    I hope you can assist me with this. I have not tried the mobile app yet, will give it a shot at the office.

    ReplyDelete