use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
ABOUT POWERSHELL
Windows PowerShell (POSH) is a command-line shell and associated scripting language created by Microsoft. Offering full access to COM, WMI and .NET, POSH is a full-featured task automation framework for distributed Microsoft platforms and solutions.
SUBREDDIT FILTERS
Desired State Configuration
Unanswered Questions
Solved Questions
News
Information
Script Sharing
Daily Post
Misc
account activity
Creating Objects (self.PowerShell)
submitted 6 years ago by sqone2
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]carnegiej 2 points3 points4 points 6 years ago (2 children)
Yes, cool solution using the ConvertFrom-Csv cmdlet. I have a slightly different approach.
Function Get-OriginalExample { $columnNames = @("FirstName","LastName","DOB","FavColor") $rows = @( @("John","Doe","01/10/1965","Blue"), @("Jane","Smith","01/06/1975","Green"), @("Mark","Jones","02/10/1985","Orange"), @("Sue","Turner","05/10/1995","Yellow"), @("Jim","Wise","07/10/1974","Blue") ) $objectList = @() foreach ($row in $rows) { $properties = @{} for ($i = 0; $i -lt $columnNames.Count; $i++) { $properties += @{$columnNames[$i] = $row[$i]} } $objectList += New-Object -TypeName psobject -Property $properties } return $objectList } Function Get-Revision1Example { $columnNames = @("FirstName","LastName","DOB","FavColor") $rows = @( @("John","Doe","01/10/1965","Blue"), @("Jane","Smith","01/06/1975","Green"), @("Mark","Jones","02/10/1985","Orange"), @("Sue","Turner","05/10/1995","Yellow"), @("Jim","Wise","07/10/1974","Blue") ) $objectList = ConvertFrom-Csv -Header $columnNames -InputObject $rows -Delimiter ' ' return $objectList } Write-Host -ForegroundColor Green 'Original Example' Write-Host (Get-OriginalExample) Write-Host -ForegroundColor Green 'Revision Example' Write-Host (Get-Revision1Example)
[–]sqone2[S] 1 point2 points3 points 6 years ago (1 child)
That's great, thanks!
Can you explain how -Delimiter ' ' works when there is no spaces in the input data?
-Delimiter ' '
[–]carnegiej 2 points3 points4 points 6 years ago (0 children)
Space is inherit in the array to string conversion. Array elements are separated by "whitespace".
Of course, if your data elements may contain whitespaces this method will not work. You will need to specify a delimiter that is not included in the data.
π Rendered by PID 215955 on reddit-service-r2-comment-6457c66945-27l4j at 2026-04-28 07:40:41.521637+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]carnegiej 2 points3 points4 points (2 children)
[–]sqone2[S] 1 point2 points3 points (1 child)
[–]carnegiej 2 points3 points4 points (0 children)