Hi
Sorry for not wrapping the code below. I have tried three different browsers and two machines and nothing happens when i select Code / Powershell
The issue:
I have two VA on a computer object
First one is a DN object picker UserDNVA and the second is a Directory string called UserDNVA-DisplayName.
Now as mentioned that are both assigned to a computer object. On the Computer object properties on the Web interface i have added UserDNVA and you select the user account. All good there. I then have the script below which i am trying to use to read that user object DN value and then go and find me the display name and add it to UserDNVA-DisplayName
The workflow starts on a change to a VA being changed on the form. The first time the VA changes to TRUE the UserDNVA-DisplayName never updates with the display name. If i set the VA to Fasle , Save , then set to TRUE it will update the displayname. I assume as its already there.
So is this a case of the attribute value has not been written to the computer object before the script runs? if so how can i get around that? I have tried adding a sleep in the script but that makes no difference at all.
function AddLicensedUserVA($Request)
{
Connect-QADService -Service "ARSERVERNAME" -Proxy
# Get Quest ARS Computer Name
$ComputerSAM = $DirObj.get("SamAccountName")
$ComputerName = $ComputerSAM.Trim("$")
# Get only the attribute you need
$Computer = Get-QADComputer $ComputerName -DontUseDefaultIncludedProperties -IncludedProperties "UserDNVA"
$UserDN = $Computer."UserDNVA"
if ($UserDN) {
# Much faster than Get-QADUser when you already have the DN
$User = Get-QADObject -Identity $UserDN -DontUseDefaultIncludedProperties -IncludedProperties "displayName"
if ($User) {
$DisplayName = $User.DisplayName
# Write the display name back to the computer object
Set-QADObject -Identity $Computer.DN `
-ObjectAttributes @{ "UserDNVA-DisplayName" = $DisplayName }
Write-Host "Updated DisplayName attribute with: $DisplayName"
}
else {
Write-Warning "User not found for DN: $UserDN"
}
}
else {
Write-Warning "Computer attribute UserDNVA is empty."
}
}


