I have a script to put these numbers in order

so that it looks like

The problem is that the below Set-Content appends only, and deletes the original text.

    $INI_Location = "\\hqfs1\users\tantony\PowerShell\CalenderGroup\config.ini"
    $Read_INI = Get-Content $INI_Location
For($Index=0; $Index -lt $List_of_Users.length; $Index++)
                $Email = ($List_of_Users[$Index]) -creplace '^[^=]*=', ''
                $Index_Plus_One = $Index + 1
                $Re_Index = "$Index_Plus_One=$Email"
                $Re_Index | Set-Content $INI_Location -Force

                Write-Host $Re_Index



You are calling Set-Content in your loop, so the last enumerated line will be set overwriting the file. Take a look at this simplified logic:

$results = foreach ($line in (Get-Content "C:\Users\Rob\Desktop\Archive\config.ini")) {
    "{0}={1}" -f $line.ReadCount, ($line -creplace '^[^=]*=', '')

$results | Set-Content "C:\Users\Rob\Desktop\Archive\config.ini"

I figured it out, thanks. I forgot to actually write the files before set-content

Writing powershell on less sleep, not paying attention to details :slight_smile: