views:

441

answers:

5

As soon as you start using PowerShell, you are likely to start collecting small, useful scripts. Managing them well is tricky.

  • Where do you keep your PowerShell scripts?
  • How do you track versions & do backups?
  • How do you synchronize between machines?
  • How do you integrate new versions of other's scripts? (Including dealing with breaking changes between their scripts and yours)
  • Do you see PowerShell V2 changing the picture?
+2  A: 

We treat PowerShell scripts just like other code. They are stored in TFS just like everything else. This handles storage, backups, versioning, and merging. Our standard build & deployment process handles moving these scripts between servers.

David
+1  A: 

I put everything into source code control including my ever expanding powershell library. This the primary way I version and spread the scripts amongst machines.

JaredPar
A: 

In a handbag under the desk...

But seriously, in source control like pretty much everything else.

Chris Lively
+1  A: 

+1 for source control. Our project's powershell scripts usually wind up in one of:

  • $/project/Trunk/Build
  • $/project/Trunk/Tests/Bin
  • $/project/Trunk/Tools/Bin

For personal scripts, at the moment I use two approaches. First I create a ~\Bin, put that in the path and put my personal PowerShell scripts there. The second approach is that I use Live Mesh to sync a PowerShell folder between all my machines. It has scripts, presentations, etc in it.s I should probably create a Bin subdir in the mesh folder and put that bin dir in my path.

V2 introduces Module support, so any modules I create would go under ~\Documents\WindowsPowerShell\Modules.

Regarding the question about using scripts from others and versioning, read up on Modules and Module Manifests in V2. I think this new feature will help.

+1  A: 

I keep my powershell profile & custom scripts in a mercurial repository. I frequently switch between my development machine at home and the development environment at work so using a distributed VCS really has its advantages: Each machine is self-contained (no need to access a source-control-server at work from home through a VPN that does not exist in my case).

I pull/push changes from the local repo on each machine to a "transfer" repo on USB stick and things still work out correctly.

froh42