title: Cannot process argument transformation on parameter 'machine'. Cannot convert value to type System.String
body: <p>I'm very new to Powershell. Im basically just using my C# logic and .net experience along with google to create this script. I dont understand why im getting the error: </p>
  
  <p>Cannot process argument transformation on parameter 'machine'. Cannot convert value to type System.String</p>
  
  <pre><code>function IterateThroughMachineSubkeys{
  (
      [Parameter()]
      [string]$machine,
      [Microsoft.Win32.RegistryKey]$subKey
  )
  
      foreach($subKeyName in $subKey.GetSubKeyNames())
      {
          Write-Host -Object ([System.String]::Format("Machine: {0} Module: {1} Version: {2}",
                              $machine.ToString(), $subKeyName.ToString(), 
                              $subKey.OpenSubKey([string]$subKeyName).GetValue("Version", "Not found", [Microsoft.Win32.RegistryValueOptions]::None)))
      }
  }
  </code></pre>
  
  <p>This is where im calling the function:</p>
  
  <pre><code>switch -CaseSensitive (ValidateConsoleInput((Read-Host).ToString()))
  {
     "E" 
     {
      IterateThroughMachineSubkeys($machine.ToString(), $subKey)
     }
     "C"
     {
      Write-Host -Object "Enter the module name to be queried in the registry:"
      GetSpecificSubkey($machine, $subkey, [string](Read-Host))
     }
  
  }
  </code></pre>