PowerShell Set-ADUser

      An update of multiple fields within Active Directory on multiple accounts from sourced file.

    #Declare Arrays which are the headers of the CSV file
    $SAM= @()
    $title= @()
    $department= @()
    $office= @()
    $company= @()

    #Imports data from a formatted CSV File and loops through each entry
    Import-Csv C:\Temp\UserAccountChanges.csv | ForEach-Object {

    # I like to make sure 
    # there are no white spaces 

    $SAM=$_.SAM.Trim()
    $title=$_.title.Trim()
    $department=$_.department.Trim()
    $office=$_.office.Trim()
    $company=$_.company.Trim()

    # Consolidate entries to add to the description line 
    $description="$Office, $department, $title"

    Try{

            Set-ADuser $SAM -title $title -Department $department -Office $office -company $company -Description $description -ErrorAction Stop 
            
            write-host "Process Completed"
            
            Get-ADuser $SAM -Properties * | Select SamAccountName, Office, Title, Department, Company, Description

        }Catch{

             #\\ Write Out Error Message \\
            Write-host Processing Halted Not All Account Revised  $_.Exception.Message

        }

    }       

2020 | Scott W. Head  |  Sr. Systems Admin | Certified Microsoft Windows Server Administrator