add all aliases to user account

Deni Garo 41 Reputation points
2020-10-21T08:44:02.887+00:00

Hi all,

I have a csv file with all aliases which we need to add to user accounts under proxyaddresses. CSV file contains name,sam,upn, emailaddress and all aliases. Problem here is that some of the users have up to 8 aliases and my question is how to add those aliases with ps. I understand that i need to use foreach but what to do when you have multiple entries. All aliases are in separate column in excel and my question is how to add those in script

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,504 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Rich Matheisen 46,476 Reputation points
    2020-10-21T19:08:43.737+00:00

    A quick search for "powershell modify proxyaddresses" would have supplied you with an answer very quickly.
    how-to-bulk-update-proxyaddresses-attribute

    0 comments No comments

  2. Ian Xue (Shanghai Wicresoft Co., Ltd.) 35,996 Reputation points Microsoft Vendor
    2020-10-22T07:13:20.91+00:00

    Hi,
    You need multiple loops. The outer loop traverse the accounts and the inner loop traverse the 8 aliases, like this

    $users = Import-Csv file.csv  
    foreach($user in $users){  
        get-asduser -filter {SamAccountName -eq $user.sam} ...| ForEach-Object{  
            $_.alias1  
            $_.alias2      
            ...  
        }  
    }  
    

    Best Regards,
    Ian

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

    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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.