0

The code is running properly. But this is creating the multiple duplicate entries in CSV file and Parent properties i am not getting the values.

$List = $web.Lists
$ctx.Load($List)
#$ctx.Load($List.ContentTypes)
$ctx.ExecuteQuery()
$ResultCollection = @()
foreach($CT in $List)
  {
        
 
        $ctx.Load($CT.ContentTypes)
        $ctx.ExecuteQuery()
        
        
        foreach($cc in $CT.ContentTypes)
        {
        #Write-Host $cc.Name
        #Write-Host $cc.DocumentTemplate
       # Write-Host $cc.DocumentTemplateUrl
       # Write-Host $cc.Description 
        #Write-Host $cc.Group  
       # Write-Host $cc.Id
        #Write-Host $cc.Parent
        

$Result = New-Object PSObject


                        $Result | Add-Member -type NoteProperty -name "SourceURL" -value $Url
                        $Result | Add-Member -type NoteProperty -name "WebURL" -value $Subweb.Url
                        $Result | Add-Member -type NoteProperty -name "ContentTypeName" -value $cc.Name
                        $Result | Add-Member -type NoteProperty -name "CTDocumentTemplate" -value $cc.DocumentTemplate
                        $Result | Add-Member -type NoteProperty -name "CTDocumentTemplateUrl" -value $cc.DocumentTemplateUrl
                        $Result | Add-Member -type NoteProperty -name "CTGroup" -value $cc.Group 
                        $Result | Add-Member -type NoteProperty -name "CTDescription" -value $cc.Description
                        $Result | Add-Member -type NoteProperty -name "ContentTypeID" -value $cc.Id
                        $Result | Add-Member -type NoteProperty -name "CTParentType" -value $cc.Parent
                        
                        $ResultCollection+=$Result;
  
     }
     #$FileName = $SiteCollectionName + "_DocuTemplateInfo"
     $ResultCollection | Export-Csv -path "C:\UserData\z00476kp\Documents\ExportItems\CTTemplateInfo_Modified.csv" -Append -Encoding UTF8  -notypeinformation
                     
        
        
     }Write-Host "CSV Exported"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.