Title: Get the Content type Usage.
Description:
Get the list and document library details about where selected content type is using in site.
Out Put: Out Put will generate in CSV file if match the given content type.
Script:
Description:
Get the list and document library details about where selected content type is using in site.
Out Put: Out Put will generate in CSV file if match the given content type.
Script:
- Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
- Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
- $Usermailid="lakku@myblore.onmicrosoft.com"
- $myPassword=Read-Host -Prompt "Password" -AsSecureString
- $Url="https://myblore.sharepoint.com/sites/fci"
- $context=New-Object Microsoft.SharePoint.Client.ClientContext($Url)
- $context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Usermailid, $myPassword)
- $context.Load($context.Web.Lists)
- $context.ExecuteQuery()
- $date = (Get-Date).ToString(“MM/dd/yyyy”)
- $OutPutFilename="ContentTypes-$date.csv";
- "Site URL"+ "," +"ListName"+ "," +"ContentType" | Out-File -Encoding Default -FilePath $OutPutFilename;
- foreach( $ll in $context.Web.Lists)
- {
- $context.Load($ll.ContentTypes)
- try
- {
- $context.ExecuteQuery()
- }
- catch
- {
- }
- foreach($cc in $ll.ContentTypes)
- {
- if ($cc.Name -eq "ConteTypeName1" -Or $cc.Name -eq "ConteTypeName2")
- {
- $ll.Url + "," + $ll.Title + "," + $cc.Name | Out-File -Encoding Default -Append -FilePath $OutPutFilename;
- }
- }
- }