PowerShell In GUI Blog

PowerShell GUI Box Just In A Few Clicks

In response to the comment about using IsePack

with one comment

A recommendation for using PowerShellPack’s IsePack Copy-ColoredAsHtml has been made in the comment to my post. I’m not a big fan of this huge package, but this is worth testing for publishing.

I use the same code copy-pasted from an ISE tab:

cls
#region WordPress posting code test
#this is a test of Powershell code coloring
[string]$stringVar1 = "string 1";
[string]$private:stringVar2 = 'string 2';
[string]$script:stringVar3=
@'
string data
'@
[scriptblock]$global:sb = {{Write-Host scriptblock}.Invoke();};
function
write1{Write-Host $stringVar1;}
function private:write2
{param([string]$str2 = '')
Write-Host $str2;}
function script:write3
#this is a function
{
Write-Host $script:stringVar3;
}
function global:Print-SB
{
<#
.SYNOPSIS
This is a code coloring test.
.DESCRIPTION
This test function represents an advanced Powershell function syntax.

.PARAMETER Param
Demonstrates how a scriptblock can be passed as a reference.

.EXAMPLE
PS C:\> Print-SB ([ref]$sb)
#>
[CmdletBinding()]
param(
[Parameter(Position=0, Mandatory=$true)]
[ref]$Param
)
Begin{}
Process{$Param.Value.Invoke()}
End{}
}
write1
private:write2 $private:stringVar2;
script:write3
Print-SB ([ref]$global:sb)
#endregion WordPress posting code test

Below is the result of IsePack code preparation:

cls            
#region WordPress posting code test            
#this is a test of Powershell code coloring            
[string]$stringVar1 = "string 1";            
[string]$private:stringVar2 = 'string 2';            
[string]$script:stringVar3=            
@' string data '@            
[scriptblock]$global:sb = {{Write-Host scriptblock}.Invoke();};            
function            
write1{Write-Host $stringVar1;}            
function private:write2            
{param([string]$str2 = '')            
Write-Host $str2;}            
function script:write3            
#this is a function            
{            
Write-Host $script:stringVar3;            
}            
function global:Print-SB            
{            
 Print-SB ([ref]$sb) #>            
[CmdletBinding()]            
param(            
[Parameter(Position=0, Mandatory=$true)]            
[ref]$Param            
)            
Begin{}            
Process{$Param.Value.Invoke()}            
End{}            
}            
write1            
private:write2 $private:stringVar2;            
script:write3            
Print-SB ([ref]$global:sb)            
#endregion WordPress posting code test

This looks great and very similar to the hand-made colored code from my post. But who has stolen my advanced function’s comment?! ūüôā All the text between <# and C:\> inclusively erased as a cow licked out.

Advertisements

Written by Alexander Petrovskiy

May 5, 2011 at 6:30 pm

Posted in ISE, Powershell, WordPress

Tagged with

One Response

Subscribe to comments with RSS.

  1. […] Who is the winner? Give the answer at last, may ask the intrigued reader. Well, the testing is almost over and soon comes the final. Two fightings were conducted, the honesty and independence is kept by using the same test script. […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: