Script create multi users with Windows PowerShell MAC address Change RRS feed

  • Question

  • This is the link original script that you are provide:
    function Select-FileDialog 
    param([string]$Title,[string]$Directory,[string]$Filter="CSV Files (*.csv)|*.csv")
    [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
    $objForm = New-Object System.Windows.Forms.OpenFileDialog
    $objForm.InitialDirectory = $Directory
    $objForm.Filter = $Filter
    $objForm.Title = $Title
    $objForm.ShowHelp = $true
    $Show = $objForm.ShowDialog()
    If ($Show -eq "OK")
    Return $objForm.FileName
    $FileName = Select-FileDialog -Title "Import an CSV file" -Directory "C:"
    $ExchangeUsersOU = "OU=ExchangeUsers" 
    $domain = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
    $DomainDN = (([System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()).Domains | ? {$_.Name -eq $domain}).GetDirectoryEntry().distinguishedName
    $final = "LDAP://$DomainDN"
    $DomainPath = [ADSI]"$final"
    $cOU = $DomainPath.Create("OrganizationalUnit",$ExchangeUsersOU)
    $UserInformation = Import-Csv $FileName
    $OUPath = "LDAP://$ExchangeUsersOU,$DomainDN" 
    $UserPath = [ADSI]"$OUPath"
    Write-Host "---------------------------------------------------------------"
    Write-Host "Creating LAB Users"
    Write-Host ""
    Write-Host "---------------------------------------------------------------"
    Foreach ($User in $UserInformation){
    $CN = $User.samAccountName
    $SN = $User.Surname
    $Given = $User.givenName
    $samAccountName = $User.samAccountName
    $Display = $User.DisplayName
    $LABUser = $UserPath.Create("User","CN=$CN")
    Write-Host "Creating User: $User.samAccountName"
    $LABUser.Put("description", "Lab User - created via Script")
    $Pwrd = $User.Password
    Write-Host "Script Completed"
    The PowerShell script was modified for my environment. in that scenario MAC address must be enable in AD. while uploading CSV file I have a data, it was uploaded and users are created but I can't re-write or modify MAC address for bulk users MAC address. Even can't change using PowerShell same CSV method. Kindly provide me a solution. Thanks in advance. 
    • Edited by DKaarthik Wednesday, December 30, 2020 7:26 AM
    Wednesday, December 30, 2020 7:25 AM

All replies