Last active
February 23, 2016 20:28
-
-
Save rheid/6c671eab99ba0e1c4b14 to your computer and use it in GitHub Desktop.
Create IIS WebSite from Folder-Struktur
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Path = "C:\inetpub\wwwroot\static" | |
$Folders = Get-ChildItem $Path -attributes D | |
$loop = 0 | |
foreach ($folder in $Folders) | |
{ | |
#Get Folder-Informationen form Filessystem | |
$loop = $loop + 1; | |
$sitefilepath = $folder.Fullname | |
$sitehostname = $folder.name | |
#Check Replacement with www | |
$a = $sitehostname | |
[regex]$regex = '\.' | |
$count = $regex.matches($a).count | |
If ($count -gt 1) { | |
$sitehostname = $folder.name | |
Write-Host "Create now IIS-Website with Host:" $sitehostname -ForegroundColor Green | |
New-WebSite -Name $sitehostname -Port 80 -HostHeader $sitehostname -PhysicalPath $sitefilepath | |
} | |
$sitehostname = "www." + $folder.name | |
Write-Host "Create now IIS-Website with Host:" $sitehostname -ForegroundColor Green | |
New-WebSite -Name $sitehostname -Port 80 -HostHeader $sitehostname -PhysicalPath $sitefilepath | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment