#Variables $File = "Change to the path where you saved YourCSVFile.csv" $Log = New-Item -ItemType File -Path "Change to the path where you you want to save the txt file.txt" -Force #Import csv $usercsv = Import-Csv -path $file -Delimiter ',' #Check if user file is empty. if ($Usercsv -eq $null) { write-host "No Users Found in Input File" exit 0 } #Get total number of users in CSV file and begin processing. $count = $Usercsv | Measure-Object | Select-Object -expand count Write-Host "Found " $count "Users to import." Write-Host "Processing Users.....`n" $index = 1 ForEach ($user in $usercsv) { Write-Host "Processing User " $index " of " $count $Name = $User.Name $telephoneNumber = $User.telephoneNumber $NumberAndExt = $User.NumberAndExt $Extension = $User.Extension #User not enabled in Lync Write-Host "Creating Normalization Rules " $User.Name -Foregroundcolor Green New-CsVoiceNormalizationRule -Parent NameOfYourDialPlan -Name "$Name Normalization Rule" -Pattern "(\$NumberAndExt)|($Extension)|($telephoneNumber)|(\+$telephoneNumber)|(\+1$telephoneNumber)|(1$telephoneNumber)" -Translation "$Extension" -Priority 2 -Verbose $index=$index+1 #Check if last command failed. If it does, log it. if(!$?) { Add-Content -Path $Log -Value "$($Name) not enabled. $(Get-Date)$($error[0])" continue } }