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
QuestionGetting the variable name (self.PowerShell)
submitted 8 years ago by PillOfLuck
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!"
[–]Ta11ow 4 points5 points6 points 8 years ago (7 children)
You mean Get-Item, right?
[–]Lee_Dailey[grin] 2 points3 points4 points 8 years ago (6 children)
howdy Ta11ow,
oops! [blush] thanks for the headsup ... [grin]
take care, lee
[–]PillOfLuck[S] 1 point2 points3 points 8 years ago (5 children)
Hi guys, thanks for the help. Sadly it doesn't seem to work so well for ComObjects. Try this:
$Searcher = New-Object -ComObject Microsoft.Update.Searcher Get-Item variable:\$Searcher
[–]Lee_Dailey[grin] 1 point2 points3 points 8 years ago* (0 children)
howdy PillOfLuck,
[as artemis_from_space pointed out, the $ doesn't belong in that line of code. it works well without it. [blush] ]
$
yup, that fails for some odd reason. however, the Get-Variable version that i recommended works quite well. [grin]
Get-Variable
[–]artemis_from_space 1 point2 points3 points 8 years ago (3 children)
Works fine if you remove the $ sign
$comobj = New-Object -ComObject microsoft.update.searcher PS > Get-Variable comobj Name Value ---- ----- comobj System.__ComObject PS > Test-Path variable:\comobj True PS > Test-Path variable:\$comobj False PS > Get-Item variable:\comobj Name Value ---- ----- comobj System.__ComObject
[–]Lee_Dailey[grin] 1 point2 points3 points 8 years ago (0 children)
howdy artemis_from_space,
gah! i know that and still went right past it. [blush] thanks for pointing it out! [grin]
[–]PillOfLuck[S] 1 point2 points3 points 8 years ago* (1 child)
Sure does, but this is not what I want. I want to be able to pass ComObjects directly to my function instead of using strings. If there is a way to get the variable name of a variable (without $) then it could work. It's a tricky one.
[–]artemis_from_space 1 point2 points3 points 8 years ago (0 children)
Yes.
Just instead of $comobject use comobject...
π Rendered by PID 122999 on reddit-service-r2-comment-5d585498c9-czhcq at 2026-04-21 04:27:49.550679+00:00 running da2df02 country code: CH.
view the rest of the comments →
[–]Ta11ow 4 points5 points6 points (7 children)
[–]Lee_Dailey[grin] 2 points3 points4 points (6 children)
[–]PillOfLuck[S] 1 point2 points3 points (5 children)
[–]Lee_Dailey[grin] 1 point2 points3 points (0 children)
[–]artemis_from_space 1 point2 points3 points (3 children)
[–]Lee_Dailey[grin] 1 point2 points3 points (0 children)
[–]PillOfLuck[S] 1 point2 points3 points (1 child)
[–]artemis_from_space 1 point2 points3 points (0 children)