-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreateRedirectsFromList.ps1
More file actions
23 lines (21 loc) · 953 Bytes
/
createRedirectsFromList.ps1
File metadata and controls
23 lines (21 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#Script grab list of names from csv and creates site and bindings
#gets Ip from server
#Use along with this line (before) to get list of sites: .\appcmd.exe list site /text:name | findstr redirect (this gives you a list of redirects on the server)
$ip=((ipconfig | findstr [0-9].\.)[0]).Split()[-1]
#uses the same pool for all redirects (create manually first!)
$pool = "redirect"
Import-CSV D:\sites.csv -Header nombre | Foreach-Object{
#variable preparation
$name = $_.nombre
$site = "redirect_"+$name
$path = Join-Path -Path 'D:\Data\sites\' -ChildPath $site
#creates the site
New-Website -Name $site -ApplicationPool $pool -Force -PhysicalPath $path
#removes wildcard bindings
Get-WebBinding -Port 80 -Name $site | Remove-WebBinding
#adds site bindings
New-WebBinding -Name $site -IPAddress $ip -Port 80 -HostHeader $name
New-WebBinding -Name $site -IPAddress $ip -Port 80 -HostHeader $name"some.domain.com"
#starts site
Start-Website $site
}