2

At the moment I m trying to use this:

Add-PSSnapin microsoft.sharepoint.powershell

#Get Web
$web = Get-SPWeb http://...

#Get List
$list = $web.Lists["List1"]

$list.DefaultView.ViewFields | Write-Host

And then I get this:

LinkTitle
Status
h48p

But I need the internal title from the column. These are the static names.

Can somebody help me?

1

Try using below:

$list.fields | select Title, InternalName, StaticName

References:

  1. SharePoint–Finding Column Display and Internal Names.
  2. Get List Fields in SharePoint using PowerShell.
| improve this answer | |
  • Thanks for your quick reply! But thats not what i needed. I only need the "Title" of the columns from the current view. – Fuxx117 Feb 3 at 7:58
0

use the below code, I just tested this in SharePoint 2013, Kindly update with the site url, list name, view name in the below code.

Add-PSSnapin "Microsoft.SharePoint.PowerShell"

$site = Get-SPSite "YOUR SITE URL"
$web = $site.OpenWeb()
$list = $web.Lists["YOUR LIST NAME"]
foreach ($view in $list.Views) #Get all views in lists 
    { 

         if($view.Title -eq "YOUR VIEW NAME"){
            $spView = $web.GetViewFromUrl($view.Url) #Grab views URL 
            Write-Host "View Name: " $view.Title  ##View title 
            Write-Host "------------------------------------------------------" 
            Write-Host "Field Name | Field Type | Field Internal Name " 
            Write-Host "------------------------------------------------------" 
            foreach ($spField in $spView.ViewFields) #Loop through all view URLs and get Fields (columns) 
            { 
                foreach ($field in $list.Fields) #Get all fields in lists 
                { 
                    if($spField -eq $field.Title) #if field in lists equals field in views 
                    { 
                        Write-Host $spField " | " $field.Type " | " $field.InternalName -ForegroundColor Green #Write out each field (column)                         
                    } 
                } 
            } 
            Write-Host "------------------------------------------------------" 
            Write-Host " " 
        }
    }     

Remove-PSSnapin "Microsoft.SharePoint.PowerShell"
| improve this answer | |
0

Here is the answer i needed:

foreach ($names in $list.DefaultView.ViewFields)
{
    $list.Fields.GetField($names).Title
}

Now I get only the title from columns of the default view.

| improve this answer | |
  • Did you solve your issue? Or is this more information for your question? If it's the latter, it would be better to update your question rather than posting an update as an Answer. – Tally Feb 3 at 11:12

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.