I’m trying to import a csv file using a variable that the user is prompted for in a previous step. If I read the contents of $csvimportfilepath, the path is perfect, but when I try to use that variable for the -path parameter in Import-CSV, I get “Import-Csv : Cannot find drive. A drive with the name ”c’ does not exist.”
Replacing the variable in the import-csv with the contents of $csvimportpath works perfectly. Some googleing suggested that the double-quotes around the path was the problem and single quotes were the solution, so that’s why I replace them. I’ve been working at this for a while and can’t find what I’m doing wrong. I’m sure it’s something obvious. Below is my code as it’s currently written.
$csvimportfilepath = Read-Host -Prompt "Please enter the path to the CSV file you want to use. Dragging and dropping works best" $csvimportfilepath = $csvimportfilepath.Replace('"',"'") $csvimportfile = Import-Csv -Path "$csvimportfilepath"