0

I try to print Authors of all items of docset list in powershell script:

Clear-Host

$web = Get-SPWeb "http://dogovor.ab.ru"
$list = $web.Lists["Agreements"]

$AllItems = $list.Items
foreach ($t in $AllItems)
{
    if ($t.ContentType.Name -eq "Agreement")
    {
        $t.Properties["Author"] # <- null

        $t
    }
}

but the property "Created By" (internal name "Author") is always null, while I can see it on form.
May be there are a list of properties to retrieve or something else.. Thanks for answers!

2 Answers 2

1

Instead of using hard code the name its better to use.

[Microsoft.SharePoint.SPBuiltInFieldId]::Author

Your code could look something like this

$url = "<url>"
$list = "<list title>"
$ctName = "<name contenttype>"
$web = Get-SPWeb $url
$list = $web.Lists[$list]

$list.Items | % {
   $item = $_
   if ($item.ContentType.Name -eq $ctName)
   {
       $item[[Microsoft.SharePoint.SPBuiltInFieldId]::Author]
   }
}
1
  • Thanks for refactoring, but this not helps Commented Jul 2, 2014 at 7:00
0

Use $t["Author"] instead of $t.Properties["Author"]

1
  • tried, same result Commented Jul 2, 2014 at 5:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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