-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build-ManagedPaths.ps1
32 lines (31 loc) · 981 Bytes
/
Build-ManagedPaths.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
# Requires:
# Log.ps1
function Build-ManagedPaths{
[CmdletBinding()]
param(
[Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$True)]
[Microsoft.SharePoint.PowerShell.SPWebApplicationPipeBind]
$WebApplication,
[Parameter(Position=1, Mandatory=$true)]
[System.Xml.XmlElement]
$Config
)
process {
$webApp = $WebApplication.Read()
$Config.Path | ForEach-Object {
$pathName = $_.RelativeUrl
$managedPath = Get-SPManagedPath -WebApplication $webApp | Where-Object {$_.Name -eq $pathName}
if (!$managedPath) {
$pathParams = @{
RelativeURL = $pathName
WebApplication = $webApp
}
if ([System.Convert]::ToBoolean($_.Explicit)) { $pathParams.Add("Explicit", $null) }
New-SPManagedPath @pathParams > $null
Log "Information" "Managed path $($_.RelativeUrl) has been created successfully."
} else {
Log "Information" "Managed path $($_.RelativeUrl) already exists."
}
}
}
}