creating an object to a cmdlet "Get-ItemProperty"

hello folks, I'm an amateur w/ poweshell and I like to know if this possible, what I like to add as an object is the "pcname"
something like

Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion | select myobjects... "PC name or ENV:pc (HOSTNAME)"

is this even possible?


the truth is that this cmdlet doesnt have an option for remote computer...and I'm having to send a psexec to connect to PS then send the command instructions....I know it's bit messy and the results are more so,  but then again I'm Workin w/ what I have since my environment doesn't have remoting enable...and to be honest I think the ports are blocked. my security guy is a no, no, no...

thanks for helping
LVL 3
ivan rosaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CESNetwork AdministratorCommented:
Let's back up... what exactly are you trying to accomplish?  If remoting is not enabled then there may be another cmdlet that could be useful
0
ivan rosaAuthor Commented:
Thanks CES,

this is the command that i'm doing to remote PCs

Get-ItemProperty 'HKLM:\SOFTWARE\ProHance Mate Service\*' | Select-Object PSChildName, ManagerHost, ManagerPort, OrganizationCode"

Open in new window


this is what i'm trying to get
Get-ItemProperty 'HKLM:\SOFTWARE\ProHance Mate Service\*' | Select-Object PSChildName, ManagerHost, ManagerPort, OrganizationCode, Computername"
0
CESNetwork AdministratorCommented:
so you want to see PSChildName, ManagerHost, ManagerPort, OrganizationCode, Computername in the output?

if so, I'd change from select-object to format-list
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

ivan rosaAuthor Commented:
yes, this is correct

I have tried format-list but I'd like to have it in format-table out-put

PSChildName, ManagerHost, ManagerPort, OrganizationCode, Computername
0
CESNetwork AdministratorCommented:
so what does format-table produce that you don't like?

Get-ItemProperty 'HKLM:\SOFTWARE\ProHance Mate Service\*' | ft PSChildName, ManagerHost, ManagerPort, OrganizationCode
0
ivan rosaAuthor Commented:
format-table is what i 'd like to have

by the way, your advise wouldn't work cause the "ft" would need to be piped | at the end and not at the begining ... not to mention i would get the output in various lines as opposed everything in one line(format-table)... and still woudln't provide me a PC name. this is why I'd like to add that property...
Get-ItemProperty 'HKLM:\SOFTWARE\ProHance Mate Service\*' | ft PSChildName, ManagerHost, ManagerPort, OrganizationCode

thanks for looking though
0
footechCommented:
You can use the following to include the computer name in the output (it makes use of a calculated property).
Get-ItemProperty 'HKLM:\SOFTWARE\ProHance Mate Service\*' | Select-Object PSChildName, ManagerHost, ManagerPort, OrganizationCode,@{n="ComputerName";e={$env:computername}}

Open in new window


If you had PS Remoting enabled, it would include a property for the remote computer automatically.  It's also possible to query the registry via .Net methods, but it's more complex and requires the remote registry service to be running.
0
David Johnson, CD, MVPOwnerCommented:
I would get the remote registry module from codeplex
https://blogs.technet.microsoft.com/pstips/2014/05/26/useful-powershell-modules/
0
ivan rosaAuthor Commented:
Hi Footech, I was also trying to do something like that..but didn't work....

$pcname|Select-Object -Property @{n='pcname'}
@{n='pcname'; e={$env:COMPUTERNAME}}


However i think what you provided is much neat, however gives me an error But, if I change it to single quotes then i start getting the property name although computername value comes out blank

Select-Object PSChildName, ManagerHost, ManagerPort, OrganizationCode, @{n='ComputerName'; e={$env:computername}}

Open in new window


i'll  take a look of that repo David J
0
ivan rosaAuthor Commented:
I just fixed it.  like this :)

Get-ItemProperty 'HKLM:\SOFTWARE\ProHance Mate Service\*' | Select-Object PSChildName, ManagerHost, ManagerPort, OrganizationCode, @{n='ComputerName'; e={hostname}} |format-table

Open in new window


thanks all for your support specially footech for the push
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
footechCommented:
Only reason I can think of that you needed a modification is your use of psexec.  I know things can get tricky, playing around with quotes and parentheses when trying to use a mix of PowerShell and other utilities.

Glad you got it working.
0
ivan rosaAuthor Commented:
he gave me the idea i needed to get my goal right
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.