QFDev
QFDev

Reputation: 9008

IIS switch paths using a script

Not quite sure how to achieve this, or if it's at all possible? I currently have two websites defined in IIS.

These sites work out of two physical folders on the C drive.

I am using Web Deploy from Visual Studio 2012 to push any new deployments to MySite_Staging, which let's say is running out of MySite_SlotA. When I've carried out some cursory checks I stop MySite_Staging then I go into MySite_Production and change the path to MySite_SlotA. This is about as seamless as I can make the deployment process on a single web-server.

My question is, can I write some kind of Powershell script or bat file that will switch the paths for me? I'm not great with Powershell but happy to look into this if it has the potential to automate this routine.

Upvotes: 2

Views: 1152

Answers (1)

Andy_Vulhop
Andy_Vulhop

Reputation: 4789

I know this is a bit of necromancy reviving this, but I just had a similar need for some powershell to change the physical path of a web app in iis. There's a nice one-liner you can use (technically 2 since you need to import a library).

Import WebAdministration
Set-ItemProperty 'IIS:\Sites\Default Web Site' -Name PhysicalPath -Value C:\Deploy\MyAwesomeWebsitePhysicalPath

Obviously, you'd need to change Default Web Site and C:\Deploy\MyAwesomeWebsitePhysicalPath to whatever suits your situation.

Upvotes: 2

Related Questions