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: '&' { '&' }
12: '<' { '≤' }
13: '>' { '>' }
14: '"' { '"' }
15: '''' { ''' }
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 !!!
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



