#-----Function to Load SharePoint PowerShell Environment----#
function LoadSharePointPowerShellEnvironment
{
write-host "Setting up PowerShell environment for SharePoint..." -foregroundcolor Yellow
Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue
write-host "SharePoint PowerShell Snapin loaded." -foregroundcolor Green
}
function Create-SPManagedPath
{
param ($webApplicationUrl, $managedPathName)
$managedPath = Get-SPManagedPath -WebApplication $webApplicationUrl -Identity $managedPathName -ErrorAction SilentlyContinue
if ($managedPath -ne $null)
{
Write-Host "Managed path $managedPathName already exists."
return
}
Write-Host "Creating managed path $managedPathName ..."
New-SPManagedPath –RelativeURL $managedPathName -WebApplication $webApplicationUrl
Write-Host "Managed path $managedPathName created sucessfully" -foregroundcolor Green
}
LoadSharePointPowerShellEnvironment
Create-SPManagedPath "http://mywebappurl" "logical"
No comments:
Post a Comment