Why will an email address not populate in a new SharePoint entry?

Laird Mark D. MacLachlan 11 Reputation points
2024-06-28T15:56:53.7766667+00:00

I have a PowerShell script used to decommission servers in our environment. My code is successfully creating the new entry and populating all properties with the exception of the Assigned Tech. This is a "Person or Group" field. I have it set to Work E-Mail. To get the value for assigned tech I am doing the following: $AssignedTech = (Get-ADUser $ENV:UserName -Properties userPrincipalName -Server ServerName.my.company.local | Select UserPrincipalName).UserPrincipalName

I have verified this has my work email in it. I post to the Sharepoint site using the following. I have tried enclosing the $AssignedTech in quotes, also tried using [string]$AssignedTech. It is still blank. The Assigned Tech field name has a space in it so I have verified the field name is actually Assigned_x0020_Tech. Can anyone see why this is not populating? I am banging my head trying to figure this one out.

 $params = @{
   fields = @{

        "Title"                            = $DecomServer;

        "IP_x0020_Address"                 = "$ip";

        "Assigned_x0020_Application"       = $Application;

        "Domain"                           = $Domain;

        "Machine_x0020_Type"               = $MachineType;

        "Change_x0020_Ticket_x0020_Number" = $ChangeControl;

        "Assigned_x0020_Tech"              = $AssignedTech;

        "OSVersion"                        = $OS;

        "DateTurnedOff"                    = Get-Date;

        "RemoveDate"                       = (Get-Date).AddDays(60)

        }

}

New-MgSiteListItem -SiteId $siteId -ListId $listId -BodyParameter $params
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,612 questions
0 comments No comments
{count} votes