Instead of writing a series of If statements you can use a Switch statement, which is equivalent to VBScript’s Select Case statement:

$page = Get-CurrentPage;
switch ($page.PageChildOrderRule) {
0 {"Undefined sort order. "}
1 {"Most recently created page will be first in list"}
2 {"Oldest created page will be first in list"}
3 {"Sorted alphabetical on name"}
4 {"Sorted on page index"}
5 {"Most recently changed page will be first in list"}
6 {"Sort on ranking, only supported by special controls"}
7 {"Oldest published page will be first in list"}
8 {"Most recently published page will be first in list"}
default {"No idea what that means!"}
}

How to Write For and For Each Loops

To write a For statement use code similar to this:

for ($a = 1; $a -le 10; $a++) {$a}

By comparison, a For Each statement might look like this:

foreach ($i in Get-ChildItem .)
{ $i.PageTypeName }

How to Write Do Loops

To write a Do loop use code like the following, replacing the code between the curly braces with the code to be executed on each iteration of the loop. Oh: and replacing the code inside the parentheses with the loop condition:

$a = 1
do {$a; $a++}
while ($a -lt 10)

$a = 1
do {$a; $a++}
until ($a –gt 10)

How to Use .NET Objects and Classes

To use a .NET Framework class static method enclose the class name in square brackets, then separate the class name and the method using a pair of colons:

How to “Interrogate” an Object

To get information about the properties and methods of an object retrieve an instance of that object and then “pipe” the object to the Get-Member cmdlet. For example, this command returns the properties and methods available when working with processes:

Get-Item . | Get-Member

More tips coming soon… In the mean time please download the fresh version of the plugin with the latest improvements: