I am trying to import a CSV file with powershell in a database, with the path defined in a variable. But it doesn't seem to work.
$path = "C:\Users\Admin\Desktop\TestFolder\file.txt" Import-CSV -Header ("header1","header2","header3") -Path $path
The above doesn't work, and I am not sure why. If I print
$path I do get the correct path, and if I run
Import-CSV with the path directly in it, it also work fine.
Write-Host $path C:\Users\Admin\Desktop\TestFolder\file.txt Import-CSV -Header ("header1","header2","header3") -Path C:\Users\Admin\Desktop\TestFolder\file.txt header1 test123 header2 test345 header3 test567 header1 test789 header2 test901 header3 test123 etc...
Using Windows Server 2012 Standard, and PowerShell 2.
Any help is appreciated,
My full code looks like this, but this doesn't work. I am trying to watch a folder with PowerShell and then import it to SQL Server 2012. The folder watch works perfectly but I can't seem to get the import to work. I figured the problem is with
$DataImport and thus I went back to the basics to figure out what the problem was. I tried the very basic setup of
Import-CSV as mentioned above but this (in its plain version as above) doesn't work.. so I figured I am using