SharePoint Server
A family of Microsoft on-premises document management and storage systems.
2,422 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
We recently migrated from SharePoint On-Premises to SharePoint Online, most of the files in a Library are .html none of them works in browser after the migration when I click on a files it download automatically instead of opening them in browser, is there a way to convert all .html files in a library to .aspx ?
Below PowerShell Script should help your requirement:
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#Config Parameters
$SiteURL = "https://YourTenant.SharePoint.com/sites/sharatha"
$ListName = "YourLibraryName"
$BatchSize = 500
#Setup Credentials to connect
$Cred = Get-Credential
$Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
Try {
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Cred
#Get the web and List
$Web=$Ctx.Web
$List=$web.Lists.GetByTitle($ListName)
$Ctx.Load($List)
$Ctx.ExecuteQuery()
Write-host "Total Number of Items Found in the List:"$List.ItemCount
$Query = New-Object Microsoft.SharePoint.Client.CamlQuery
$Query.ViewXml = "<View Scope='RecursiveAll'><Query><OrderBy><FieldRef Name='ID' Ascending='TRUE'/></OrderBy></Query><RowLimit Paged='TRUE'>$BatchSize</RowLimit></View>"
Do {
#Get items from the list in batches
$ListItems = $List.GetItems($Query)
$Ctx.Load($ListItems)
$Ctx.ExecuteQuery()
$Query.ListItemCollectionPosition = $ListItems.ListItemCollectionPosition
Write-host Renaming $($ListItems.count) Items Starting from Item ID $ListItems[0].ID
#Loop through each file in the Library and Rename File(s)
foreach ($item in $ListItems)
{
if($item.FileSystemObjectType -eq [Microsoft.SharePoint.Client.FileSystemObjectType ]::File) {
$destFileUrl = $item["FileRef"].ToString().Replace(".html",".aspx")
$item.File.MoveTo($destFileUrl, [Microsoft.SharePoint.Client.MoveOperations]::Overwrite)
$Ctx.ExecuteQuery()
}
}
#$Ctx.ExecuteQuery()
} While ($Query.ListItemCollectionPosition -ne $null)
Write-host -f Green "All Items Renamed!"
} Catch {
write-host -f Red "Error Renaming List Items!" $_.Exception.Message
}
Thanks & Regards,