How to use a common powershell profile inside a command

I would like to know how to share and maintain an updated profile ($ profile.AllUsersAllHosts) between all my employees. Since I am the only one who makes POSH scripts in a team, I would like to create a kind of structure that ensures distribution to its team members.

Is there a way to load a profile from a url? Or should I use a local profile to map a network drive and then download the .ps1 file? Other ideas?

thanks

+4
source share
2 answers

Instead of fighting the system, I suggest that you save the general profile on the network, and then ask people to specify this profile in the profile on the computer (user or machine profile):

. \\server\share\CommonProfile.ps1 

Another option is to create a shortcut for PowerShell.exe with the -NoExit parameter, which executes a common profile, for example.

 PowerShell.exe -NoExit -Command "& {. \\server\share\CommonProfile.ps1 }" 
+7
source

Well, for those interested here, this is a complete recipe:

1- On each workstation of your team, change the profile to a point source to a common "profile"

 -> . \\server\share\commonProfile.ps1 

2- On the shared profile, edit PSModulePath and add your sharedFolder containing your modules (we check if the allready shared folder is on the way)

  if($env:PSModulePath -match "\\\\server\\share\\modules" -eq $false){ $env:PSModulePath = $env:PSModulePath + ";\\server\share\Modules" } 

3 Place the modules created in \\ server \ share \ Modules and import them from commonProfile.

Additionally:

  • Use SVN or so to update your modules folder

  • Use Redmine to track your developments and bugs.

  • Automatically create documents so that your colleagues know what you are doing (I use a modified version of the Out-Html script found at poshcode.org

alt text

Finally, Just Relax;)

+4
source

All Articles