PowerShell dependency management PowerShell dependency management powershell powershell

PowerShell dependency management


I created a solution for you that I think will fit your situation. I created it based off of the song playlist methodology. I created an xml document where you would list each of your scripts individually and in another node in the same document you list the scripts you want to copy for each project. I have created a working example of this below. Though it is not elegant when it comes to managing a few hundred script files or alot of projects but it gets the job done.

PS1 Script

[xml]$XML = gc "C:\XMLFile1.xml"$Scripts = $XML.Root.Scripts.Script$Projects = $XML.Root.Projects.Projectforeach($Project in $Projects){    $ProjectLocation = $Project.CopyPath    $ProjectScripts = $Project.Script    foreach($Script in $ProjectScripts){        $ScriptPath = ($Scripts|?{$_.ID -eq $Script.ID}|Select Path).Path        Copy-Item -Path $ScriptPath -Destination $ProjectLocation    }}

XMLFile

<Root>  <Scripts>    <Script ID="1" Path="C:\1.PS1"></Script>    <Script ID="2" Path="C:\2.PS1"></Script>    <Script ID="3" Path="C:\3.PSM1"></Script>  </Scripts>  <Projects>    <Project Name="Project1" CopyPath="\\Server\Share\Project1">      <Scripts ID="1"/>    </Project>    <Project Name="Project2" CopyPath="C:\Projects\Project2">      <Scripts ID="1"/>      <Scripts ID="3"/>    </Project>  </Projects></Root>


A simple solution would be to use something like DropBox. You can see how I use it for my PowerShell Scripts here: http://www.ravichaganti.com/blog/?p=1963

You can get a DropBox account with 2GB of free space http://db.tt/1DID1mR. 2GB, in my opinion, is more than enough for simple scripts. There are also other choices in the market. However, I recommend DropBox. The free account supports restoring 30 days old file versions.