Why cant i remove the suffix from import-csv

Clinton van Axel 126 Reputation points
2021-05-26T21:03:25.52+00:00

I want to remove the suffix from an import-csv UPN

But i keep getting that the value is null.

$ADUsers = Import-Csv C:\temp\guid.csv -Delimiter ";"

ForEach ($User in $ADUsers) { 
%{$User.UserPrincipalName.Split('@')[0]}
}
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,462 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Rich Matheisen 45,906 Reputation points
    2021-05-26T21:41:24.74+00:00

    Have you verified that the CSV contains a column named "UserPrincipalName"?

    0 comments No comments

  2. Ian Xue (Shanghai Wicresoft Co., Ltd.) 34,271 Reputation points Microsoft Vendor
    2021-05-27T02:24:10.117+00:00

    Hi,

    Is the value of $ADUsers.UserPrincipalName null? If so, please check the header and the delimiter of the CSV file.

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments