Active Directory: Please can we have a added functionality to pick up Job Titles/Role Names

Copper Contributor

Reason for request: To save time entering job titles and reduce human error.  To enhance the use of MS Project to wider team/Company.

We would like a single source of truth - Active Directory to fetch the required key data

 

Thank you!

 

Link: https://answers.microsoft.com/en-us/msoffice/forum/all/active-directory/f0237bc1-c14a-4099-8b7...

1 Reply

Hello @wah ,

There is nothing out of the box to do this, it will require a custom solution. You could quite easily do this with a scheduled PowerShell script for example, here is a blog post I wrote a few years ago now: https://pwmather.wordpress.com/2016/11/07/update-projectonline-resource-custom-field-values-using-po... 

The code is not available on the download link anymore but I have copied it below. Please note, I haven't tried this code for 5+ years so it might / will need updating but should help get you started. Please update and fully test on a non-production instance first so that you are happy with it. The script is provided “As is” with no warranties etc.

#Add in libraries - update for the correct location
#SharePoint Online CSOM DLL
Import-Module 'C:\Users\paulmather\OneDrive for Business\External Disk\SharePointOnlineCSOMDLLs\16.1.5521.1200\Microsoft.SharePoint.Client.dll'
#Project Online CSOM DLL
Import-Module 'C:\Users\paulmather\OneDrive for Business\External Disk\SharePointOnlineCSOMDLLs\16.1.5521.1200\Microsoft.ProjectServer.Client.dll'

#install the Azure AD PowerShell module - downloaded from here http://connect.microsoft.com/site1164/Downloads/DownloadDetails.aspx?DownloadID=59185
#Set Azure AD user details - update for correct username, password and CSV file location
$ADusername = "userName"
$ADpassword = "password"
$CSVfilelocation = "C:\Temp\ADusersFULLAD.csv" 
$secureADpassword = ConvertTo-SecureString $ADpassword -AsPlainText -Force
$ADcreditials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $ADusername,$secureADpassword
Import-Module MSOnline
connect-msolservice -credential $ADcreditials
Get-MsolUser -All | Select DisplayName, UserPrincipalName, Title | Export-CSV -NoTypeInformation -Path $CSVfilelocation

#Set PWA details - update for correct URL, username and password
$PWAInstanceURL = "https://paulmather.sharepoint.com/sites/PWA"
$PWAUserName = "userName"
$password = "password"
$securePass = ConvertTo-SecureString $password -AsPlainText -Force 

#Custom field ID - update for correct custom field internal ID
$customFieldInternalName = "Custom_3fa3e04146a4e61180d100155d507a05"

$projContext = New-Object Microsoft.ProjectServer.Client.ProjectContext($PWAInstanceURL)
[Microsoft.SharePoint.Client.SharePointOnlineCredentials]$spocreds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($PWAUserName, $securePass); 
$projContext.Credentials = $spocreds

#load resources
$projContext.Load($projContext.EnterpriseResources)
$projContext.ExecuteQuery() 

#Import CSV file created previously and update associated resources
Import-Csv $CSVfilelocation | Foreach-Object { 
    try {        
        $resName = $_.DisplayName   
        $resource = $projContext.EnterpriseResources | select Id, Name | where {$_.Name -eq $resName}
        if($resource -ne $null){
            $res = $projContext.EnterpriseResources.GetByGuid($resource.Id)
            $res[$customFieldInternalName] = $_.Title
            $projContext.EnterpriseResources.Update()
            $projContext.ExecuteQuery()
            Write-host -ForegroundColor Green "'$resName' has been updated"
            }
        else {
            Write-host -ForegroundColor Yellow "'$resName' not found"
            }
        }
    catch{
        write-host -ForegroundColor Red "Add error occurred whilst attempting to update resource: '$resName'. The error details are: $($_)"
        }
}

 Paul