Below is the Powershell script to Enable Folder creation option on Document Library.
[System.Reflection.Assembly]::LoadFile("C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll")| Out-Null
[System.Reflection.Assembly]::LoadFile("C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll")| Out-Null
function Get-SPOAllWeb
{
param (
[Parameter(Mandatory=$true,Position=1)]
[string]$Username,
[Parameter(Mandatory=$true,Position=2)]
$AdminPassword,
[Parameter(Mandatory=$true,Position=3)]
[string]$Url
)
$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword)
$ctx.Load($ctx.Web.Webs)
$ctx.Load($ctx.Web)
$lists = $ctx.web.Lists
$list = $lists.GetByTitle("Underwriting")
$ctx.Load($list)
$ctx.ExecuteQuery()
Write-Host $ctx.Web.Url
#for enabling folder creation
# $list.EnableFolderCreation =$true;
# $list.Update()
# $ctx.ExecuteQuery()
}
if($ctx.Web.Webs.Count -eq 0)
{
}
else
{
foreach ($web in $ctx.Web.Webs)
{
Get-SPOAllWeb -Username $Username -AdminPassword $AdminPassword -Url $web.Url
}
}
Get-SPOAllWeb -Username "USERNAME" -AdminPassword (ConvertTo-SecureString "PASSWOR" -AsPlainText -Force) -Url "SHAREPOINT SITE COLLECTION URL"
[System.Reflection.Assembly]::LoadFile("C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll")| Out-Null
[System.Reflection.Assembly]::LoadFile("C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll")| Out-Null
function Get-SPOAllWeb
{
param (
[Parameter(Mandatory=$true,Position=1)]
[string]$Username,
[Parameter(Mandatory=$true,Position=2)]
$AdminPassword,
[Parameter(Mandatory=$true,Position=3)]
[string]$Url
)
$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword)
$ctx.Load($ctx.Web.Webs)
$ctx.Load($ctx.Web)
$lists = $ctx.web.Lists
$list = $lists.GetByTitle("Underwriting")
$ctx.Load($list)
$ctx.ExecuteQuery()
Write-Host $ctx.Web.Url
#for enabling folder creation
# $list.EnableFolderCreation =$true;
# $list.Update()
# $ctx.ExecuteQuery()
}
if($ctx.Web.Webs.Count -eq 0)
{
}
else
{
foreach ($web in $ctx.Web.Webs)
{
Get-SPOAllWeb -Username $Username -AdminPassword $AdminPassword -Url $web.Url
}
}
Get-SPOAllWeb -Username "USERNAME" -AdminPassword (ConvertTo-SecureString "PASSWOR" -AsPlainText -Force) -Url "SHAREPOINT SITE COLLECTION URL"
Comments
Post a Comment