July 12, 2012

SharePoint PowerShell Script: Disable Modal Windows for Lists

# Created by Dennis Alzoubi    
# Version 1.1
# Last Updated 6/18/2012 8:28 am
# Purpose: Disables modal window for all lists in specified site
param([Parameter(Position=0, Mandatory=$true, HelpMessage="Url of Site")][string]$SiteUrl,
      [Parameter(Position=1, Mandatory=$true, HelpMessage="Name of List. 'All' for all Lists")][string]$ListName)
 
if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{
    Write-Host 'Reading in SharePoint SnapIn'
    Add-PsSnapin Microsoft.SharePoint.PowerShell;
}
 
Write-Host "Disabling Modal Window for: " $SiteUrl
$site = Get-SPSite $SiteUrl
$web = $site.OpenWeb()
 
if ($ListName -eq "All")
{
    foreach($currList in $web.Lists)
    {
        $currList.NavigateForFormsPages = $true
        $currList.Update()
        Write-Host ("List: " + $currList.title + " successfully updated")
    }
}
else
{
    $currList = $web.lists["$ListName"]
    $currList.NavigateForFormsPages = $true
    $currList.Update()
    
    Write-Host ("List: " + $currList.title + " successfully updated")
}
 
$web.Dispose()
$site.Dispose()
 
Write-Host "Press any key to continue ..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

No comments:

Post a Comment