Solved

.framework class powershell remote machine

Posted on 2014-03-24
7
319 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 40

Assisted Solution

by:footech
footech earned 500 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 40

Assisted Solution

by:footech
footech earned 500 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

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 40

Accepted Solution

by:
footech earned 500 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
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…

733 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