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

%3CLINGO-SUB%20id%3D%22lingo-sub-2541909%22%20slang%3D%22en-US%22%3EActive%20Directory%3A%20Please%20can%20we%20have%20a%20added%20functionality%20to%20pick%20up%20Job%20Titles%2FRole%20Names%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2541909%22%20slang%3D%22en-US%22%3E%3CP%3EReason%20for%20request%3A%20To%20save%20time%20entering%20job%20titles%20and%20reduce%20human%20error.%26nbsp%3B%20To%20enhance%20the%20use%20of%20MS%20Project%20to%20wider%20team%2FCompany.%3C%2FP%3E%3CP%3EWe%20would%20like%20a%20single%20source%20of%20truth%20-%20Active%20Directory%20to%20fetch%20the%20required%20key%20data%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fanswers.microsoft.com%2Fen-us%2Fmsoffice%2Fforum%2Fall%2Factive-directory%2Ff0237bc1-c14a-4099-8b74-37b1fa38b00c%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ELink%3A%20https%3A%2F%2Fanswers.microsoft.com%2Fen-us%2Fmsoffice%2Fforum%2Fall%2Factive-directory%2Ff0237bc1-c14a-4099-8b74-37b1fa38b00c%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional 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