Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

.framework class powershell remote machine

Posted on 2014-03-24
7
Medium Priority
?
355 Views
Last Modified: 2014-03-27
Hi Guys,

I can't seem to use the -computer switch in powershell when I type a .net frame class e.g :

[System.Environment]::MachineName

[System.Environment]::OSVersion

[System.Environment]::GetEnvironmentVariables()

how can I do this - run these commands on a remote machine?

Also how can I retrieve a list of all that's available under the system class?

thank you in advance.
0
Comment
Question by:Kay
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 41

Assisted Solution

by:footech
footech earned 2000 total points
ID: 39950016
Parameters like -computername are a feature of specific cmdlets in PS.  Not all cmdlets have that parameter as it wouldn't make sense.  Neither would it make sense for all (or any?) types/classes to be able to reference a remote machine.

Your best option (IMO) for running these on a remote machine is PS Remoting.  Actually, I don't think I see any other option.

If you need to see all the static methods and properties available for a class run something like the following:
[system.environment] | gm -static

Open in new window

Is that what you're referring to?  Also, in case you're not aware, gm is an alias for Get-Member.
0
 

Author Comment

by:Kay
ID: 39950353
thank you, I wanted to include .net framework classes in a script, and there are multiple servers in question.

I have heard that cmdlets are actually .net framework classes, so I am wondering could there be a way to create a new cmdlet in .net and include the -computer switch?/
0
 
LVL 41

Assisted Solution

by:footech
footech earned 2000 total points
ID: 39950809
I really haven't studied it at such a low level.  There are so many .Net Framework classes - I'm not sure what you mean by you wanted to include them in a script.
I have heard that cmdlets are actually .net framework classes
I haven't heard that.  I can't say it isn't true, but it doesn't sound right.  Cmdlets are written in C# if I remember right, and though I'm sure they include references to .Net classes, I feel there's more to it than that.  It's definitely possible to write your own cmdlet (if you know how) and include whatever functionality you want.  However, unless you have the skills and desire to be a PowerShell developer, I would recommend that you use the functionality that is already there (as I mentioned, PS Remoting seems to fit the bill here).
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Kay
ID: 39950913
thanks, problem with psremoting is that it has to enabled on every server, and I don't know if there is a quick way to do it without manually having to log into each one?

yea I really want to learn automation at an advanced level, therefore it seems like I need to lean c#.net too to become an expert.
0
 

Author Comment

by:Kay
ID: 39950920
so powershell developers make the cmdlets right for applications? example powercli used for VMware, would have been written by a powershell developer, the netapp storage also has a powershell module and this again would having been written by a powershell developer?
0
 

Author Comment

by:Kay
ID: 39950924
is the powercli module for vsphere written using c#?
0
 
LVL 41

Accepted Solution

by:
footech earned 2000 total points
ID: 39950973
I'll try to answer your posts in order.

You can enable PS Remoting with Group Policy.  There's only two or three settings (depending on environment) that need to be configured.
http://blogs.technet.com/b/heyscriptingguy/archive/2012/07/24/an-introduction-to-powershell-remoting-part-two-configuring-powershell-remoting.aspx
You can automate a ton without writing your own cmdlets.  It depends on what you want to do.

I believe so, yes. (in answer to your last two posts)
I am not a PS developer, I'm a scripter, so there's little I could tell you about the developer side.
0

Featured Post

Are You Ready for GDPR?

With the GDPR deadline set for May 25, 2018, many organizations are ill-prepared due to uncertainty about the criteria for compliance. According to a recent WatchGuard survey, a staggering 37% of respondents don't even know if their organization needs to comply with GDPR. Do you?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
A walk-through example of how to obtain and apply new DID phone numbers to your cloud PBX enabled users that are configured in Office 365. Whether you have 1, 10 or 100+ users in your tenant, it's quite easy to get them phone-enabled and making/rece…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

647 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question