After migrating content to SharePoint 2016, all date columns were in Friendly display format. Here is a way to update them across the site collection using PowerShell.
Run Microsoft PowerShell as Administrator
Add-PSSnapin "Microsoft.SharePoint.Powershell" -ErrorAction SilentlyContinue
$WebCollection = Get-SPSite "SiteUrl" -Limit All | Get-SPWeb -Limit All
foreach($site in $WebCollection){
$lists = $site.Lists
foreach($list in @($lists)){
Write-Host "Connected to $list" -ForegroundColor Yellow
foreach($field in @($list.Fields)){
$column = $list.Fields[$field.Title]
if($column.Type -eq "DateTime"){
Write-Host "Connected to " $column.Title -ForegroundColor Yellow
$column.FriendlyDisplayFormat = 1
$column.update()
}
}
}
}
You can also limit the list/library you want to do this on by using a where clause in the lists area like the following:
foreach($list in $lists |?{$_.Title -like "ListName"}){}
No comments:
Post a Comment