# Set-IIS-Paths.ps1 # Written by Greg Shackles, 2010 # http://www.gregshackles.com Import-Module WebAdministration # set this to the root folder, which contains 2 folders: "branches" and "trunk" $svnPath = "c:\svn" # path to IIS website we are looking to configure $iisPath = "IIS:\Sites\Default Web Site\" # paths to the branches $branches = Get-ChildItem ($svnPath + "\branches") $options = @{} $optionCounter = 1 # Print out trunk/branch options write-host "Select which version you want to use in IIS:" write-host "" write-host "1: Trunk" $options.Add($optionCounter.ToString(), ($svnPath + "\trunk")) write-host "---------------------" write-host "Branches:" write-host "" foreach ($branch in $branches) { $optionCounter++ $options.Add($optionCounter.ToString(), $branch.FullName) write-host "$($optionCounter): $($branch.Name)" } write-host "" # Let the user pick an option $input = "" do { $input = read-host 'Choose a version ("quit" to cancel)' } while ($input -ne "quit" -band $options.ContainsKey($input) -eq $False) # if they wanted to quit, we're done if ($input -eq "quit") { exit } write-host "" # now we can start updating IIS settings $appPath = $options.Get_Item($input) $projects = ("WebApplication1", "WebApplication2") foreach ($project in $projects) { write-host "Updating: $($project)" Set-ItemProperty ($iisPath + $project) -name physicalPath -value ($appPath + "\" + $project) } write-host "" write-host "Done!"