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!

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]
   }
}
  • Thanks for refactoring, but this not helps – Andrew Ferin Jul 2 '14 at 7:00
0

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

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.