Saturday, September 27, 2014

Update Managed Paths using PowerShell script

The following script will create the Managed Paths for the web application. This script needs the Input as CSV file. And CSV file should contains the Type,Name,WebApp as columns.
Type should contain for example - WildcardInclusion, ExplicitInclusion

Script:

$Name = @()
$Type = @()
$WebApp = @()

Import-Csv "D:\SPManagedPath.csv" |
    ForEach-Object {
        $Name += $_.Name
        $Type += $_.Type
                $WebApp += $_.WebApp
$inputNumber = Read-Host -Prompt "Please Enter to continue"  
    $Where = [array]::IndexOf($Type, $inputNumber)
    Write-Host "Name1: " $Name[$Where]
    Write-Host "Type2: " $Type[$Where]
    Write-Host "WebApp3: " $WebApp[$Where]
    New-SPManagedPath -RelativeURL $Name[$Where] -Explicit -WebApplication $WebApp[$Where]
    }

No comments:

Post a Comment