sitecore-iis.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#
# sitecore_iis.ps1
#
function Install-IIS
{
<#
 .SYNOPSIS
  Installs IIS on Windoes server
  
 .DESCRIPTION
  
 .EXAMPLE
   
 #>

[CmdletBinding()]
    param (
        [parameter()]
        [string]$ConfigurationFilePath
    )

    if( (Test-Path -Path $ConfigurationFilePath) -eq $true )
    {
        Write-Verbose "Install IIS from file"
        Install-WindowsFeature -ConfigurationFilePath $ConfigurationFilePath
    }
    else
    {
        Write-Verbose "Install Full IIS"
        import-module servermanager
        Add-WindowsFeature web-server -includeallsubfeature -IncludeManagementTools
    }
}


function New-SitecoreAppPool 
{
[CmdletBinding()]
    param (
        [parameter()]
        [string]$AppPoolName
    )

    Write-Verbose "Create new AppPool: $AppPoolName"

    New-WebappPool -name $AppPoolName -Force

    $pool = Get-Item IIS:\AppPools\$AppPoolName
    
    ## Configure pool for SXP requirements
    $pool.managedRuntimeVersion = "v4.0"
    $pool.processModel.loadUserProfile = $true
    $pool.processModel.maxProcesses = 1

    $pool | Set-Item
}


function New-SitecoreWebApp
{
[CmdletBinding()]
    param (
        [parameter(Mandatory=$true)]
        [string]$HostName,
[parameter(Mandatory=$true)]
        [string]$AppName,
[parameter(Mandatory=$true)]
        [string]$AppPath,
[parameter(Mandatory=$true)]
        [string]$AppPool
    )

    Write-Verbose "Creates a new web application named: $HostName in folder $AppPath, $AppPool"

    New-Website -Name $AppName -HostHeader $HostName -PhysicalPath $AppPath -ApplicationPool $AppPoll

New-SitecoreHostsEntry -IpAddress '127.0.0.1' -HostName $HostName
}

Export-ModuleMember -Function Install-IIS
Export-ModuleMember -Function New-SitecoreAppPool
Export-ModuleMember -Function New-SitecoreWebApp