How can I convert the below exported text to csv so that i can use it as objects in powershell. Eg:
where{$_.qlimit -eq 27}
Text:
samid qlimit qused
Administrator -1 0
Guest -1 0
admin 27 8
krbtgt -1 0
r -1 0
admin2 44 0
Another way with ConvertFrom-String (no headers in the file):
You can easily convert your table to PowerShell objects using the
ConvertFrom-SourceTable
cmdlet from the PowerShell Gallery:Result:
Use the Get-Content cmdlet to load the file, replace two or more whitespaces with a comma and convert it to
CSV
using the ConvertFrom-Csv cmdlet:If you now query your object:
You get the desired output: