######################################################### # # Script to Create the websites in all tiers. # # Created Aug 20, 2010 # Bryan Loveless # # # Requires Powershell 2.0 # # Change your Execution policy to RemoteSigned if running locally # by: Set-executionpolicy -executionpolicy RemoteSigned # #Prereqs: Have physical paths created already. # Also must have at least one site that exists. Keep the "Default" # one for now. # ######################################################## import-module webadministration $physicalpath = "C:\Projects\Websites" #New-Item iis:\Sites\$sitename -bindings @{protocol="http";bindingInformation=":80:$sitename"} -physicalPath $physicalpath\$sitename #list all websites below, IIS names are same as Physical Paths ON PURPOSE! $listofwebsites = "site1","site2","site3","YouGetTheIdeaRight","wehavelotsmore","butforthisblog","IshortendTheList" foreach ($site in $listofwebsites) { #create the site, associate with physical path. WILL OVERWRITE OLD SITE! New-Item iis:\Sites\$site -bindings @{protocol="http";bindingInformation="*:80:"} -physicalPath $physicalpath\$site -Force #Adds the HTTPS port to all sites. New-WebBinding -Name "$site" -IP "*" -Port 443 -Protocol https #stop the site after creating it Stop-Website $site } # to see what a site has, try: # get-webbinding -name "NAMEOFSITE"
If I spend some time figuring out something that might help others, and hasn't been found on the Internet by me, I will post about it. I hope to save some poor IT guy or gal some time.
Friday, August 27, 2010
create a bunch of websites using POSH
Labels:
powershell,
work
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment