I have the below script:
function copyUserSettings {
    Write-Host
    $copyFrom = Read-Host 'Which Folders Do You Want To Copy FROM?'
    Write-Host
    $copyTo = Read-Host 'Which Folders Do You Want To Copy TO? (Enter a Number OR Range eg. 12-18)'
    Write-Host
    IF ($copyTo.Contains("-")) {
        $copyToStart = $copyTo.Split("-")[0]
        $copyToEnd = $copyTo.Split("-")[1]
        $copyToStart..$copyToEnd | foreach{
            Copy-Item -Path $rootPath\FOLDER\$copyFrom\US*.DAT -Destination $rootPath\FOLDER\$_
        }
    } else {
        Copy-Item -Path $rootPath\FOLDER\$copyFrom\US*.DAT -Destination $rootPath\FOLDER\$copyTo
    }
}
The user is supposed to enter where to copy the files from (all the folder names are just a number), and where to copy the files to (also just a number), by entering a single folder name or a range (ie 12-18). If I enter a single number the above script works properly, but if I enter a range the files don't copy and I don't get any feedback error or anything.
Edit1: $rootPath is defined earlier in the script.
Edit2: Modified code above per @tnw's suggestion.
Thanks in advance for your help. If you need any more details please let me know.
 
     
     
     
    