This Community Rocks!!! Performance Counters Module Updated


This morning my good friend and PowerSheller Johan Bijnens (blog | twitter) sent me a DM saying the problem in a module for Gathering perfmon data with Powershell.

Well, And he told me the error, I thought I do not had  the environment to test so I asked him  to debug to find on which line was the error.

So we found it was in the creation of XML, a memory windows counter was made with special character (a panda dies every time someone does it)

As I am not very knowledgeable of the XML structure,  while I was researching the error, Johan already sent me the answer. A function to  replace  the Special characters (and according to him , he is just beginning in PowerShell. Very modest)

   1: function Get-XMLtext {

   2:     param(

   3:     [Parameter(Position=0, Mandatory=$true ,ValueFromPipeline = $false)] [string]$inputText

   4:     )

   5: #Credits to Johan Bijnens (@alzdba)

   6: #http://support.microsoft.com/kb/308060

   7:  #Clear-Host  

   8: #Get-XMLtext 'Brazil > then Belgium & "Belgium" < ''Brazil''  '

   9:  

  10:     -join $(switch -case ( [Char[]]$inputText ) {

  11:       '&' { '&amp;' }

  12:        '<' { '&le;' }

  13:       '>' { '&gt;' }

  14:       '"' { '&quot;' }

  15:       '''' { '&apos;' }

  16:       default { $_ }

  17:     })

  18: }

Then was just put in the module and all works fine now.

How cool is that ? I really love this community and you guys rocks !!!

Big thanks to you my friend and let´s spread the words of PowerShell !!!

Download Module

PS – I hope to see you in SQLBITS man to talk about PowerShell while we take a English Afternoon Tea ( I really do need do to this. I grew up watching movies with the famous English Afternoon Tea)

#PowerShellLifeStyle

About Laerte Junior

Laerte Junior Laerte Junior is a SQL Server specialist and an active member of WW SQL Server and the Windows PowerShell community. He also is a huge Star Wars fan (yes, he has the Darth Vader´s Helmet with the voice changer). He has a passion for DC comics and living the simple life. "May The Force be with all of us"
This entry was posted in Powershell, SQL SERVER EM GERAL, Virtual Pass BR. Bookmark the permalink.

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s