Monday, March 26, 2012

ProjectServer 2010: Create Custom Fields and Lookup Tables from PowerShell

In this post we’ll demonstrate how to create Lookup Table and Custom Fields on PWA from PowerShell.
All you need is create several objects with types from FluentPS.Model namespace and use LookupTableService or CustomFieldService to create items on ProjectServer instance.

See the full source:
$fluentps = Get-FluentPS -PWAUrl "http://localhost/PWA"

$lookup = new-object FluentPS.Model.PSLookupTableInfo
$lookup.Name = "LT Test1"
$lookup.Type = [FluentPS.Enums.PSFieldType]::Text

$lookupsToCreate = New-Object 'System.Collections.Generic.List[FluentPS.Model.PSLookupTableInfo]'
$lookupsToCreate.Add($lookup)

$fluentps.LookupTableService.CreateLookupTables($lookupsToCreate)


$cf = new-object FluentPS.Model.PSCustomFieldInfo
$cf.FieldName = "Test Field 1"

$lcf = new-object FluentPS.Model.PSLookupFieldInfo
$lcf.FieldName = "Test Lookup Field 1"
$lcf.LookupTableName = "LT Test1"

$fieldsToCreate = New-Object 'System.Collections.Generic.List[FluentPS.Model.PSCustomFieldInfo]'
$fieldsToCreate.Add($cf)
$fieldsToCreate.Add($lcf)

$fluentps.CustomFieldService.SaveOrUpdateCustomFields($fieldsToCreate, [FluentPS.Enums.PSEntityType]::Project)

Have fun!

4 comments:

  1. Buy Online Brand New Windows Server 2016 Standard edition only 299 USD for 16 cores 1 processor or 8 cores 2 processors license, included a brand new retail license with OS, please visit: http://www.halfrain.com/Microsoft-Windows-Server-2016-Retail

    ReplyDelete