Solved

.framework class powershell remote machine

Posted on 2014-03-24
7
314 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
  • 4
  • 3
7 Comments
 
LVL 39

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 39

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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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 39

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
A procedure for exporting installed hotfix details of remote computers using powershell
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

776 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