Important: The PowerShell script has to be executed with a x64 PowerShell console, otherwise any attempt to configure IIS will fail.
The following configuration steps will be executed:
- Set permissions for root directory
json['baseDirectory']
- Full Control permission for Active Directory group
json['adGroupAdministrator']
- Modify permission for Active Directory user
json['adUserBuildserver']
- Create website directory (e. g.
D:\Web\Sites\myapp-production\htdocs
) if it doesn't exist
- The name and path of the website directory will be composed as
<<BASE>>\Sites\<<NAME>>-<<ENVIRONMENT>>
with:<<Base>>
isjson['baseDirectory']
<<NAME>>
is lowercasejson['objects']['app']
<<ENVIRONMENT>>
is lowercasejson['objects']['environment']
- Set permissions for website directory
- Full Control permission for Active Directory user
json['objects']['appPoolAccount']
- Create network share for website directory
- Delete existing network share if it exists
- The name of the network share will be composed as
<<NAME>>-<<ENVIRONMENT>>-htdocs
with:<<NAME>>
is lowercasejson['objects']['app']
<<ENVIRONMENT>>
is lowercasejson['objects']['environment']
- Full Control permission for Active Directory group
['adGroupAdministrator']
- Full Control permission for Active Directory user
['adUserBuildserver']
ifjson['objects']['shareForBuildserver']
is set totrue
- Full Control permission for additional Active Directory members
json['objects']['fullControlMembers']
- The default entry allowing everyone to access the network share will be removed. Depending on the platform of the OS, the alias has to be set via
json['aliasEveryone']
:- English:
Everyone
- German:
Jeder
- English:
- Create application pool if it doesn't exist
- The name of the application pool will be composed as
<<NAME>>-<<ENVIRONMENT>>
with:<<NAME>>
is lowercasejson['objects']['app']
<<ENVIRONMENT>>
is lowercasejson['objects']['environment']
- The .NET CLR Runtime Version will be set to either
v4.0
orjson['objects']['appPoolNetRuntimeVersion']
- Set application pool identity to
json['objects']['appPoolAccount']
usingjson['objects']['appPoolPassword']
as password - Create website if it doesn't exist
- The name of the website will be composed as
<<NAME>>-<<ENVIRONMENT>>
with:<<NAME>>
is lowercasejson['objects']['app']
<<ENVIRONMENT>>
is lowercasejson['objects']['environment']
- Set bindings for the website
- Remove all existing bindings (When creating a new website with PowerShell, the default binding get's assigned. Since only one website can use the default binding, all existing bindings will be removed and only the specified ones will be set.)
- Set bindings according to
json['objects']['bindings']
- Start the website
- Copy existing code into website directory
- The specific purpose of this script was to ease the migration from one server to a new one. Due to this, there was some pre-configured code (e. g.
web.config
) that will be simply copied into the website directory. - Copy everything from
<<SOURCES>>\<<NAME>>-<<ENVIRONMENT>>\htdocs
to<<DESTINATION>>\Sites\<<NAME>>-<<ENVIRONMENT>>\htdocs
with:<<NAME>>
is lowercasejson['objects']['app']
<<ENVIRONMENT>>
is lowercasejson['objects']['environment']
<<SOURCES>>
isjson['sources']
<<DESTINATION>>
isjson['baseDirectory']
Listed below the different configuration parameters of the JSON file:
json['baseDirectory']
: The base directory of all websites.json['sources']
: The source code of the pre-configured applications that will be copied into the website directory.json['adUserBuildserver']
: The Active Directory user of the Buildserver. The user will always obtain Modify permissions on the base directory and on demand Full Control permissions on the network share (depending onjson['objects']['shareForBuildserver']
).json['adGroupAdministrator']
: The Active Directory group of the Administrators. This group will obtain Full Control permissions on the base directory and network share.json['aliasEveryone']
: The alias for Everyone that will be used to remove the default permission on a network share. It has to be set according to the OS platform, e. g.Jeder
in German ofEveryone
in English.json['objects']
: Array of JSON objects with every object representing an application to configure.json['objects']['app']
: The name of the application. It will be used for the directory structure, name of the application pool and name of the website.json['objects']['environment']
: The environment (e. g.development
,integration
,staging
orproduction
).json['objects']['appPoolAccount']
: The Active Directory user being used for the application pool's identity. The user will obtain Full Control permissions on the website directory.json['objects']['appPoolPassword']
: The password of the application pool account.json['objects']['bindings']
: An array of strings containing all the bindings that will be configured for the website.json['objects']['appPoolNetRuntimeVersion']
: This parameter is optional. The .NET CLR Runtime version that will be used for the application pool. Default value isv4.0
.json['objects']['shareForBuildserver']
: This parameter is optional. When set totrue
, the Active Directory userjson['adUserBuildserver']
will obtain Full Control permissions to the network share of the website. Default value isfalse
.json['objects']['fullControlMembers']
: This parameter is optional. An array of strings containing additional Active Directory users or groups that will obtain Full Control permissions on the website's network share.