none
PowerShell script to iterate through all SharePoint List Views output the View Names and their columns in order? RRS feed

  • Question

  • Hi there

    Do you have any PowerShell script to iterate through all SharePoint List Views output the View Names and their columns in order?

    Thanks.

    Wednesday, September 11, 2019 10:22 PM

Answers

  • Hi, Ran009,

    Please try the script below, it will output all list views with its columns in the site collection .

    #Config Variables
    $SiteURL = "you site URL" 
    #Get Credentials to connect
    $Cred = Get-Credential
     
    
        #Connect to PNP Online
        Connect-PnPOnline -Url $SiteURL -Credentials $Cred
    
     	
        $lists=Get-PnPlist
        #Get the List View from the list
        foreach($list in $lists)
    	{
        		$ListView  =  Get-PnPView -List $list.title
    		foreach($view in $ListView )
    		{
    			write-host -f Green 'List Name:'$list.title  'View Name:' $view.title
    			write-host -f Yellow 'The columns in this view'
    			write-host $view.viewfields
    			write-host
    		}
    	}

    Best Regards

    Jerry


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    • Marked as answer by ran009 Thursday, September 12, 2019 11:47 PM
    Thursday, September 12, 2019 5:40 AM