try { Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.Runtime.dll" Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" } catch { Write-Host "Problem in loading CSOM DLLs : $_.Exception.Message" -foregroundcolor black -backgroundcolor Red return } # Initialize client context $adminURL = Read-Host -Prompt "Enter Tenant Admin URL:" $username = Read-Host -Prompt "Enter user name:" $password = Read-Host -Prompt "Enter password:" -AsSecureString #$sideLoadingGuid = new-object System.Guid "AE3A1339-61F5-4f8f-81A7-ABD2DA956A7D" try{ function Get-SPOWebs($webURL){ #Get Web information and subsites $clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($webURL) $clientContext.Credentials = $credentials $Web = $clientContext.Web $clientContext.Load($Web) $clientContext.Load($Web.Webs) $clientContext.executeQuery() #Do something with the current sub-site #Write-host $Web.URL #Iterate through each subsite in the current web foreach ($Subweb in $Web.Webs) { if($Subweb.AppInstanceId -eq [GUID]::Empty){ Write-Host 'Url:' $Subweb.url # Append as child to an existing node [System.XML.XMLElement]$newXmlSiteURLElement=$oXMLRoot.appendChild($xmlDoc.CreateElement("SiteURL")) $newXmlNameTextNode = $newXmlSiteURLElement.AppendChild($xmlDoc.CreateTextNode($Subweb.url)); #Call the function recursively to process all subsites underneaththe current web Get-SPOWebs($Subweb.url) } } } } catch{ Write-Host "$_.Exception.Message" -foregroundcolor black -backgroundcolor Red return } try { # connect/authenticate to SharePoint Online and get ClientContext object.. $clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($adminURL) $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password) $clientContext.Credentials = $credentials # Enumerate all site collections $tenant = New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($clientContext) $props = $tenant.GetSiteProperties(0, $true) $clientContext.Load($props) $clientContext.ExecuteQuery() # Create a new XML File with sites root node [System.XML.XMLDocument]$xmlDoc=New-Object System.XML.XMLDocument [System.XML.XMLElement]$oXMLRoot=$xmlDoc.CreateElement("sites") $xmlDoc.appendChild($oXMLRoot) foreach($sp in $props) { Write-Host 'Url:' $sp.Url # Append as child to an existing node [System.XML.XMLElement]$newXmlSiteURLElement=$oXMLRoot.appendChild($xmlDoc.CreateElement("SiteURL")) $newXmlNameTextNode = $newXmlSiteURLElement.AppendChild($xmlDoc.CreateTextNode($sp.Url)); #$sp.Url | out-file "C:\SiteCollectionList.xml" Get-SPOWebs($sp.Url) } # Save File $xmlDoc.Save("c:\config1.xml") } catch { Write-Host "$_.Exception.Message" -foregroundcolor black -backgroundcolor Red return }
Thursday, 13 December 2018
Power Shell Script to Export all existing sitecollection URLs and its site's URL in a SharePoint Online tenant to XML file
Switching Between New And Classic SharePoint Document Library Experiences
Applies To: SharePoint Online , SharePoint Online admin center
Following are the Steps to change the classic mode Library experience to New Library experience:
1.Copy the following code and paste it into a text editor, such as Notepad.
2. Save the file, naming it CustomActions.ps1.
NOTE: You can use a different file name, but you must save the file as an ANSI-encoded text file whose extension is .ps1
3.Change to the directory where you saved the file.
4 .At the Windows PowerShell command prompt, type the following command:
./CustomActions.ps1
You may notice a change in the look and navigation of your document libraries and lists. This new experience is faster, has additional phone and tablet features, and simpler navigation. As a document library or list owner, site owner, or administrator, you may want to switch the default experience back to the previous (classic view) for a time. Keep in mind that users can change the experience in specific libraries or sites back to new if they choose.
Following are the Steps to change the New Library experience to classic mode:
1.Copy the following code and paste it into a text editor, such as Notepad.
1.Copy the following code and paste it into a text editor, such as Notepad.
Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.Runtime.dll"
$MyCredentials = Get-Credential
#Connect-SPOService -Url https://prakashinfotech-admin.sharepoint.com -credential $MyCredentials
$webUrl = 'https://prakashinfotech.sharepoint.com/sites/Form10/'
Write-Host "Press any key to continue ..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
[Microsoft.SharePoint.Client.ClientContext]$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl)
$clientContext.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($MyCredentials.UserName,$MyCredentials.Password)
$site = $clientContext.Site;
$clientContext.load($site);
$sitefeatureguid = new-object System.Guid "E3540C7D-6BEA-403C-A224-1A12EAFEE4C4"
$site.Features.Add($sitefeatureguid, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None);
$clientContext.ExecuteQuery();
Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.Runtime.dll"
$MyCredentials = Get-Credential
#Connect-SPOService -Url https://prakashinfotech-admin.sharepoint.com -credential $MyCredentials
$webUrl = 'https://prakashinfotech.sharepoint.com/sites/Form10/'
Write-Host "Press any key to continue ..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
[Microsoft.SharePoint.Client.ClientContext]$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl)
$clientContext.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($MyCredentials.UserName,$MyCredentials.Password)
$site = $clientContext.Site;
$clientContext.load($site);
$sitefeatureguid = new-object System.Guid "E3540C7D-6BEA-403C-A224-1A12EAFEE4C4"
$site.Features.Add($sitefeatureguid, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None);
$clientContext.ExecuteQuery();
2. Save the file, naming it CustomActions.ps1.
NOTE: You can use a different file name, but you must save the file as an ANSI-encoded text file whose extension is .ps1
3.Change to the directory where you saved the file.
4 .At the Windows PowerShell command prompt, type the following command:
./CustomActions.ps1
NOTE: You can use a different file name, but you must save the file as an ANSI-encoded text file whose extension is .ps1
3.Change to the directory where you saved the file.
4 .At the Windows PowerShell command prompt, type the following command:
./CustomActions.ps1
Following are the Steps to change the classic mode Library experience to New Library experience:
1.Copy the following code and paste it into a text editor, such as Notepad.
#set-executionpolicy unrestricted
Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.Runtime.dll"
$MyCredentials = Get-Credential
Connect-SPOService -Url https://prakashinfotech-admin.sharepoint.com -credential $MyCredentials
$webUrl = 'https://prakashinfotech.sharepoint.com/sites/ProviderhostedappsRnd/'
[Microsoft.SharePoint.Client.ClientContext]$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl)
$clientContext.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($MyCredentials.UserName,$MyCredentials.Password)
$site = $clientContext.Site;
$clientContext.load($site);
$sitefeatureguid = new-object System.Guid "E3540C7D-6BEA-403C-A224-1A12EAFEE4C4"
$site.Features.Remove($sitefeatureguid, $true);
$clientContext.ExecuteQuery();
#set-executionpolicy restricted
Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.Runtime.dll"
$MyCredentials = Get-Credential
Connect-SPOService -Url https://prakashinfotech-admin.sharepoint.com -credential $MyCredentials
$webUrl = 'https://prakashinfotech.sharepoint.com/sites/ProviderhostedappsRnd/'
[Microsoft.SharePoint.Client.ClientContext]$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl)
$clientContext.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($MyCredentials.UserName,$MyCredentials.Password)
$site = $clientContext.Site;
$clientContext.load($site);
$sitefeatureguid = new-object System.Guid "E3540C7D-6BEA-403C-A224-1A12EAFEE4C4"
$site.Features.Remove($sitefeatureguid, $true);
$clientContext.ExecuteQuery();
#set-executionpolicy restricted
2. Save the file, naming it CustomActions.ps1.
NOTE: You can use a different file name, but you must save the file as an ANSI-encoded text file whose extension is .ps1
3.Change to the directory where you saved the file.
4 .At the Windows PowerShell command prompt, type the following command:
./CustomActions.ps1
Subscribe to:
Posts (Atom)