VMware Cloud Community
rock425
Enthusiast
Enthusiast
Jump to solution

Powercli using remote powershell?

Hello,

Is it possible to run powercli scripts using remote powershell?

Use case:

We have multiple "jump servers" that each have access to separate datacenters that have various vsphere environments within.   Is it possible to have one central "scripting" server that houses all of our powercli scripts that we could then run the local scripts on the remote jump servers and pull back the output?    Right now, we run the scripts locally on each of the jump servers, but it would be nice to be able to have one central repository / server where I can run all scripts against all datacenters.   This would also help with keeping versioning of scripts under control.

Thanks,

0 Kudos
1 Solution

Accepted Solutions
rock425
Enthusiast
Enthusiast
Jump to solution

Thanks LucD!

In testing in the lab, everything appears to be working.      I have my scripts located on one central server and I'm able to run invoke-command to run the local script on the remote server.

One note of clarification though - PowerCLI has to be installed on the remote servers, not the repository server.

If Powercli is only installed on the repository server, it tells me that connect-viserver, etc. is not recognized as the name of a cmdlet, function, script file, or operable program....

Thanks again for your quick response!

View solution in original post

0 Kudos
5 Replies
LucD
Leadership
Leadership
Jump to solution

If you allow PowerShell remoting to that central server/repository, you can do remote sessions (New-PSSession), and start scripts remotely.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
rock425
Enthusiast
Enthusiast
Jump to solution

Thanks LucD!

Question - does powercli need to be installed on the jump server, the central server or both?

I'm hoping to test this out in our lab in the next few days.

Regards,

0 Kudos
LucD
Leadership
Leadership
Jump to solution

PowerCLI should be installed on the server where you run the scripts, in your case that would be the central server.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
rock425
Enthusiast
Enthusiast
Jump to solution

Thanks LucD!

In testing in the lab, everything appears to be working.      I have my scripts located on one central server and I'm able to run invoke-command to run the local script on the remote server.

One note of clarification though - PowerCLI has to be installed on the remote servers, not the repository server.

If Powercli is only installed on the repository server, it tells me that connect-viserver, etc. is not recognized as the name of a cmdlet, function, script file, or operable program....

Thanks again for your quick response!

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Yes, like i said you have to have PowerCLI on the server where you run the script.

You run the scripts, via the Invoke-Command cmdlet, on the remote servers, while the script source is located on the repository server.

So yes, you have to have PowerCLI on those remote servers.

My suggestion was to also run the scripts on the repository server, via a remote PSSession from wherever you are to the repository server.

But if your solution is working for your environment, that is good as well.

There is always more than one way to do stuff in PowerShell/PowerCLI :smileygrin:


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos