Hi,
I can see how that works with the variables in the command line.. I am not having problems doing that, I am having problems changing the variables inside of the actual sql script (add_location.sql) that invoke-sqlcmd is running. I tried a simple script below to see if it would work, and did not have any luck.
Thanks again for the help!
param (
[string]$ScriptFile = "C:\Users\Administrator\Downloads\DATABASE\INSTALL\XX\Add_LOCATION.sql",
[string]$Server = "localhost",
[string]$Database = "DB_POWERSHELL",
[string]$jdcfacility = "myfacilityname"
)
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | out-null
$sqlSrv = New-Object 'Microsoft.SqlServer.Management.Smo.Server' ($server)
TRAP {Write-Host -ForegroundColor Red "Error:Unable to run script" ;continue}
Invoke-SqlCMD -InputFile "$scriptfile" -ServerInstance $server -Database "$database" -v $jdcfacility