Scanner Output

Hi All, I'm trying to run the command below and I'm getting strange columns and incorrect data when the powershell scanner runs. I'm sure I'm doing something wrong, but all the documentation I've seen sounds like what I have outputting is correct.

cmd /c assoc | convertfrom-stringdata

This is the output I see when running this directly in PowerShell (truncated for your viewing sanity). It reports as a hash table via get-member.

And this is what I see when it runs the scan in PDQi.

Can anyone tell me why my columns are showing like this?



Date Votes
  • [PSCustomObject](cmd /c assoc | ConvertFrom-StringData)
  • Thank you Colby Bouma. Unfortunately, that is still producing the same output in PDQi (and Powershell) as before.

  • Sorry, I should have tried that in Inventory before posting. "cmd /c assoc" is sending an array of strings to "ConvertFrom-StringData", so it's returning an array of hashtables.

    I came up with a couple of solutions. I like the first one better because it's shorter, but the second one is probably more "correct".

    Make sure to increase the Row Limit for this scanner!

    cmd /c assoc | ConvertFrom-StringData | ForEach-Object { [PSCustomObject]@{'Extension' = [String]$_.Keys; 'Association' = [String]$_.Values} }


    cmd /c assoc | ConvertFrom-StringData | ForEach-Object { $_.GetEnumerator() | ForEach-Object { [PSCustomObject]@{'Extension' = $_.Key; 'Association' = $_.Value} } }

    This last one makes 1 column per extension. It's not much fun to look at, but could be useful for Collections.

    [PSCustomObject](ConvertFrom-StringData ((cmd /c assoc) -join "`n"))
  • Thank you Colby Bouma, that works great...exactly what was needed. Seems like there should be a function for that rather then needing the for loop but the first one worked perfect. I appreciate your help!


Please sign in to leave a comment.

Didn't find what you were looking for?

New post