title: Input string was not in a correct format powershell
body: <p>I'm trying to create a simple performance counter with powershell using an example code found <a href="https://stackoverflow.com/questions/3605146/creating-editing-performance-counters-in-a-powershell-script-or-command-line">here</a>. In the last line i replaced the variables with strings:</p>
  
  <pre><code>[System.Diagnostics.PerformanceCounterCategory]::Create("catname", "catinfo", [Diagnostics.PerformanceCounterCategoryType]::SingleInstance, $CounterCollection); 
  </code></pre>
  
  <p>When i'm run the script, i get the following error: </p>
  
  <pre><code>Exception calling "Create" with "4" argument(s): "Input string was not in a correct format."
  At C:\...\setup_test.ps1:9 char:56
  + [System.Diagnostics.PerformanceCounterCategory]::Create &lt;&lt;&lt;&lt; ("catname", "catfaszom",     [Diagnostics.PerformanceCounterCategoryType]::SingleInstance, $CounterCollection); 
  + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
  + FullyQualifiedErrorId : DotNetMethodException
  </code></pre>
  
  <p>I printed some extra info with</p>
  
  <pre><code>$error[0]|format-list -force
  </code></pre>
  
  <p>The additional result is:</p>
  
  <pre><code>Exception             : System.Management.Automation.MethodInvocationException: Exception calling "Create" with "4" argument(s): "Input string was not in a correct format." ---&gt; System.FormatException: Input string was not in a correct format.
                         at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer&amp; number, NumberFormatInfo info, Boolean parseDecimal)
                         at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
                         at System.Diagnostics.PerformanceCounterLib.GetStringTable(Boolean isHelp)
                         at System.Diagnostics.PerformanceCounterLib.get_NameTable()
                         at System.Diagnostics.PerformanceCounterLib.get_CategoryTable()
                         at System.Diagnostics.PerformanceCounterLib.CategoryExists(String machine, String category)
                         at System.Diagnostics.PerformanceCounterCategory.Create(String categoryName, String categoryHelp, PerformanceCounterCategoryType categoryType, CounterCreationDataCollection counterData)
                         at Create(Object , Object[] )
                         at System.Management.Automation.DotNetAdapter.AuxiliaryMethodInvoke(Object target, Object[] arguments, MethodInformation methodInformation, Object[] originalArguments)
                         --- End of inner exception stack trace ---
                         at System.Management.Automation.DotNetAdapter.AuxiliaryMethodInvoke(Object target, Object[] arguments, MethodInformation methodInformation, Object[] originalArguments)
                         at System.Management.Automation.ParserOps.CallMethod(Token token, Object target, String methodName, Object[] paramArray, Boolean callStatic, Object valueToSet)
                         at System.Management.Automation.MethodCallNode.InvokeMethod(Object target, Object[] arguments, Object value)
                         at System.Management.Automation.MethodCallNode.Execute(Array input, Pipe outputPipe, ExecutionContext context)
                         at System.Management.Automation.ParseTreeNode.Execute(Array input, Pipe outputPipe, ArrayList&amp; resultList, ExecutionContext context)
                         at System.Management.Automation.StatementListNode.ExecuteStatement(ParseTreeNode statement, Array input, Pipe outputPipe, ArrayList&amp; resultList, ExecutionContext context)
  TargetObject          : 
  CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
  FullyQualifiedErrorId : DotNetMethodException
  ErrorDetails          : 
  InvocationInfo        : System.Management.Automation.InvocationInfo
  PipelineIterationInfo : {}
  PSMessageDetails      : 
  </code></pre>
  
  <p>What is wrong whit my code?</p>
  
  <p>Update:</p>
  
  <p>The whole code:</p>
  
  <pre><code>$ccdTypeName = 'System.Diagnostics.CounterCreationData'
  $CounterCollection = New-Object System.Diagnostics.CounterCreationDataCollection
  
  #create as many counters as we'd like, and add them to the collection. here's just one:
  $CounterCollection.Add( (New-Object $ccdTypeName "TestCtr1", "Test counter 1 description", NumberOfItems32) )
  
  #create the category with the counter collection
  [System.Diagnostics.PerformanceCounterCategory]::Create("asd", "dasd", [Diagnostics.PerformanceCounterCategoryType]::SingleInstance, $CounterCollection);
  $error[0]|format-list -force
  </code></pre>
  
  <p>I tried to run it on an another pc, and it worked without any errors.</p>