I have a PowerShell script:
param ( [Parameter(Mandatory=$true)][string]$input, [Parameter(Mandatory=$true)][string]$table ) Write-Host "Args:" $Args.Length Get-Content $input | % { [Regex]::Replace($_, ",(?!NULL)([^,]*[^\d,]+[^,]*)", ",'`$1'") } | % { [Regex]::Replace($_, ".+", "INSERT INTO $table VALUES (`$1)") }
Write-Host part
is for debugging.
I run it as .\csvtosql.ps1 mycsv.csv dbo.MyTable
(from powershell) and get
Args: 0 Get-Content : Cannot bind argument to parameter 'Path' because it is an empty s tring. At C:\temp\csvtosql.ps1:7 char:12 + Get-Content <<<< $input | + CategoryInfo : InvalidData: (:) [Get-Content], ParameterBinding ValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAl lowed,Microsoft.PowerShell.Commands.GetContentCommand
I get exactly the same error with any parameters passed, also the same errors if I try to use named parameters.
What can lead to the fact that the parameters will not be transferred?
UPDATE : PowerShell ISE asks me for these parameters using GUI hints, and then gives me the same error that they are not being reported.
source share