none
Creating an Enterprise Custom Field with PowerShell and CSOM RRS feed

  • Question

  • Hello everyone,

    I'm trying to create Custom Fields using CSOM and PowerShell and for some reason I can't populate the CustomFields property.

    This is my current code

    Add-Type -Path "<...>\Microsoft.SharePoint.Client.dll"

    Add-Type -Path "<...>\Microsoft.ProjectServer.Client.dll"

    [Microsoft.SharePoint.Client.SharePointOnlineCredentials]$spocreds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Credentials.UserName, $Credentials.Password)

    $context = New-Object Microsoft.ProjectServer.Client.ProjectContext($PWAUrl)
    $context.Credentials = $spocreds
    $customFields = $context.CustomFields
    $context.Load($customFields)
    $context.ExecuteQuery()
    $customFields

    The result of this is

    format-default : The collection has not been initialized. It has not been requested or the request has not been
    executed. It may need to be explicitly requested.
        + CategoryInfo          : NotSpecified: (:) [format-default], CollectionNotInitializedException
        + FullyQualifiedErrorId : Microsoft.SharePoint.Client.CollectionNotInitializedException,Microsoft.PowerShell.Comma
       nds.FormatDefaultCommand

    I can't seem to get the CustomFields to be popullated.

    Any ideas?

    Wednesday, June 19, 2019 10:53 AM

All replies