Monday, November 23, 2015

Update date friendly format for all lists in a site collection

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$site= Get-SPWeb "SITEURL"
$ColumnName ="Modified"
foreach ($web in $site.Site.AllWebs)
{
    Write-Host "Updating Site: " $web.Title
    for ($i=0; $i -lt $web.lists.count; $i++)
    {
        $list = $web.lists[$i]
        Write-Host $List.Title
        if($list.fields.ContainsField($ColumnName))
        {
            $column = $list.Fields[$ColumnName]
            $column.FriendlyDisplayFormat = [Microsoft.SharePoint.SPDateTimeFieldFriendlyFormatType]::Disabled
            $column.Update()
            Write-Host "Field type updated on: $($list.Title)"
        }
    }
    $web.Dispose();
}

No comments:

Post a Comment