Mapping a Publication to a web application using PowerShell
You can map Publications to web applications within the Content Manager Explorer user interface, and this is the method we recommend. With the required access, however, you can also do this using a PowerShell cmdlet.
About this task
To run PowerShell scripts for software, you require a machine that meets the following requirements:
- PowerShell
- You require Microsoft Windows PowerShell 5.1. You can download Microsoft Windows Management Framework 5.1, which includes Microsoft Windows PowerShell 5.1, from this location: http://aka.ms/wmf5download
- Operating system
- You require an operating system that supports both the required PowerShell software and any software for the database you intend to install. As a general rule, ensure that the latest (security) updates are installed on your operating system.
- Microsoft .NET Framework
-
You require a .NET Framework version. The one to use depends on your Windows Server operating system version:
- If you run Microsoft Windows Server 2022, you can use Microsoft .NET Framework 4.8.1. You can download Microsoft .NET Framework 4.8.1 from the following location: https://dotnet.microsoft.com/en-us/download/dotnet-framework/net481
- If you run Microsoft Windows Server 2019 x64, you must use Microsoft .NET Framework 4.8. You can download Microsoft .NET Framework 4.8 from the following location: https://dotnet.microsoft.com/en-us/download/dotnet-framework/net48
- Security
- You need to be logged in as a user with sufficient security clearance. For example, to run a script that installs a database, you must be logged in as a user with rights to create that database.
Procedure
Create a mapping from each web application to its corresponding Publication in Content Manager by running the following command (once for each mapping):
Add-TtmMapping -Id MAPPINGID -CmEnvironmentId CMENVIRONMENTID
-PublicationID "tcm:X-Y-Z" -WebApplicationId WEBAPPID -RelativeUrl RELURL
where:
- MAPPINGID is a unique ID for this mapping, for example,
StagingMicrosite01Mapping. - CMENVIRONMENTID is the unique ID of this (possibly scaled-out) Content Manager instance. Set this to the value of the environment variable called
TRIDION_CM_ENVIRONMENT_IDon any Content Manager server machine. - tcm:X-Y-Z is the Content Manager URI of the Publication to which you are mapping, that is, the Publication that contains the content for this specific web application, for example,
"tcm:0-1-1". - WEBAPPID is the unique ID of the web application you are mapping to, for example,
StagingMicrosite01. If you are mapping to the default web application of a website with an IDExample, the ID of the web application to specify here for WEBAPPID would beExample_RootWebApp. - RELURL is the relative URL from the web application context to the mapped location. If the mapped location is the root, omit this parameter.