SOLVED

Powershell for sharepoint online

Brass Contributor

Hi, I have a powershell script related to SharePoint 2013 server. Can this be converted to work on online, as the site is community site template which was available in SharePoint 2013 and its also available in SharePoint online. we are having an issue with community SharePoint site online and need to use the same script which fixed the issue on SP 2013 community site. Below is the script

 

$web = Get-SPWeb <Affected web URL here>  
$categorieslist = $web.Lists["Categories"]    
$categorieslist.Title = "Categories_old"  
$categorieslist.RootFolder.MoveTo($web.Url + "/lists/categories_old")  
$categorieslist.Update()  
Write-Host "Categories list issue fixed..."  
Disable-SPFeature -Identity CommunitySite -Url $web.Url  
Enable-SPFeature -Identity CommunitySite -Url $web.Url  
Write-Host "Community Site Feature reactivated..." 

 

3 Replies
best response confirmed by Audi86 (Brass Contributor)
Solution
Hello,
There is no Get-SPWeb in SPO PS so I would say you will need to explore with PnP SharePoint module

https://pnp.github.io/powershell/cmdlets/Get-PnPWeb.html

and

https://pnp.github.io/powershell/cmdlets/Disable-PnPFeature.html

hi @Andres Gorzelany
This code did some stuff. Renamed the old categories and created the new Categories but my URL didn't update to new categories, any advise for this ?

I reset Site Features manually from site settings

 

 

 

Connect-PnPOnline -Url https://[your-tenant].sharepoint.com/sites/[your-site]
$categorieslist = Get-PnPList -Identity "[GUID of the list you want to move]"  
$categorieslist.Title = "Categories_old"  
$categorieslist.RootFolder.MoveTo("https://[your-tenant].sharepoint.com/sites/[your-site]" + "/lists/categories_old")  
$categorieslist.Update() 
Invoke-PnPQuery 
Write-Host "Categories list issue fixed..."  

 

 

I couldn't test your scenario specifically yet but remember that you have to use Disable-PnPFeature/Enable-PnPFeature

I am not sure you will find equal parity of cmdlets/parameters, so I also recommend testing on a test site/list. You will probably need to adjust some things. For example, Disable-PnpFeature does not have a Url Parameter but will run the cmd on the site you are connected to.
1 best response

Accepted Solutions
best response confirmed by Audi86 (Brass Contributor)
Solution
Hello,
There is no Get-SPWeb in SPO PS so I would say you will need to explore with PnP SharePoint module

https://pnp.github.io/powershell/cmdlets/Get-PnPWeb.html

and

https://pnp.github.io/powershell/cmdlets/Disable-PnPFeature.html

View solution in original post