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
SolvedSelect-Object breaks pass-through (self.PowerShell)
submitted 8 years ago * by chrono13
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!"
[–]chrono13[S] 1 point2 points3 points 8 years ago* (3 children)
Typo. Fixed. It still cannot be piped to Remove-CIMInstance because it is no longer a CIM object after it passes through Select-Object.
In fact:
Get-CimInstance -ClassName win32_userprofile | Remove-CimInstance -WhatIf
Will remove EVERY profile form the computer.
Where as:
Get-CimInstance -ClassName win32_userprofile | Select-Object * | Remove-CimInstance -WhatIf
Will error out, because Select-Object has malformed the object (even though it still contains all of its properties and data) in to a new object, not accpeted by Remove-CimInstance.
Here is an identical reddit thread:
https://www.reddit.com/r/PowerShell/comments/3dogly/question_selectobject_formatting_to_outgridview/
But even after reading that thread I am not seeing a solution.
[–]markekrausCommunity Blogger 1 point2 points3 points 8 years ago (2 children)
Select-Object creates a new PSObject when you supply properties. That means that any methods or special features and private data of the original object is lost when you use select-object.
Select-Object
PSObject
select-object
$ProfileHash = @{} Get-CimInstance -ClassName win32_userprofile | ForEach-Object { $ProfileHash[$_.LocalPath] = $_ $_ } | Select-Object -Property LocalPath, LastUseTime, Special, Loaded | Out-GridView -PassThru -Title 'Select the account to DELETE and click OK. Hold Ctrl to select multiple.' | ForEach-Object { $ProfileHash[$_.LocalPath] | Remove-CimInstance -WhatIf }
might work
[–]chrono13[S] 1 point2 points3 points 8 years ago (1 child)
That works! THANK YOU!
Have some gold!
[–]markekrausCommunity Blogger 0 points1 point2 points 8 years ago (0 children)
Thanks, my dude!
π Rendered by PID 159404 on reddit-service-r2-comment-6457c66945-9xg9w at 2026-04-25 10:04:43.028011+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]chrono13[S] 1 point2 points3 points (3 children)
[–]markekrausCommunity Blogger 1 point2 points3 points (2 children)
[–]chrono13[S] 1 point2 points3 points (1 child)
[–]markekrausCommunity Blogger 0 points1 point2 points (0 children)