This topic contains 4 replies, has 3 voices, and was last updated by
July 27, 2018 at 6:11 pm #105502
Does anyone have any articles, suggestions, recommendations, etc. for when creating cmdlets that you want to be executed locally and/or remotely.
Just as an example. If I wanted to create a cmdlet that installs software, but I want to be able to use that same cmdlet to install software on a list of machines, one of those machines being my local computer what are some best practices for setting up your functions to do this?
I am currently building out a new module and find myself struggling with how to complete this.
Thanks in advance!
July 27, 2018 at 7:24 pm #105508ParticipantPoints: 527Rank: Major Contributor
Do some research on Powershell repositories. Ideally, you would setup an internal PowershellGet repository that would allow you to go to any system with PowershellGet capabilities and simply do a Install-Module MyModule. Powershell 5+ has native capabilities and Powershell 3-4 require additional software to enable this functionality.
Some other things to note, you should check out Chocolatey, which is providing *nix software installation capabilities.
Lastly, if you are trying to do DevOps and want to ensure software is installed on these systems, you can take a look at Powershell Desired State Configuration (DSC). This is more of a policy driven approach that ensures settings, software, etc. are the same against multiple systems.
July 27, 2018 at 8:16 pm #105509
Thanks, Rob. I completely understand what you are saying.
I was looking more for understanding best practices for creating cmdlets that allow for local and remote execution. Example:
Get-Service -Name blah -ComputerName SomewhereElse
Get-Service -name blah
So the same cmdlet runs but gets data from a remote computer and from the local computer. I want to understand how this works, so I can follow best practices when creating a cmdlet that does something similar.
July 27, 2018 at 9:20 pm #105512ParticipantPoints: 43Rank: Member
That has more to do with how you design your script/function/cmdlet. Use Get-Help and check out the following help topics:
Those are good topics to look at. Check out the other topics listed under 'SEE ALSO' at the end of each one. Also check out the PowerShell Style and Practices Guide. Hope that helps!
July 30, 2018 at 7:36 pm #105614
Thanks for the details. I went read through what you suggested over the weekend. It has a lot of great detail on many topics and I learned a lot.
I also checked out POSH\Style&PraticeGuide and left a comment there. I hope someone gets back to me.
Unfortunately, I didn't find any examples of implementing a cmdlet for local and remote execution. If you find any, can you add here?
The topic ‘Creating functions for local and remote execution’ is closed to new replies.