My script is as follows
New-Alias -Name sqlpackage -Value "C:\Program Files (x86)\Microsoft SQL
Server\130\DAC\bin\sqlpackage.exe"
$command = "sqlpackage /Action:Publish /SourceFile:$sourceFile /tcs:$TargetConnectionString /p:ScriptRefreshModule="+"$ScriptRefreshModule"+" /p:ScriptNewConstraintValidation="+"$ScriptNewConstraintValidation"+ `
" /p:GenerateSmartDefaults="+"$GenerateSmartDefaults"+" /p:BlockOnPossibleDataLoss="+"$BlockOnPossibleDataLoss"+" /p:BackupDatabaseBeforeChanges="+"$BackupDatabaseBeforeChanges"+ `
" /v:ErrorEmailRecipients="+"$ErrorEmailRecipients"+" /v:DeploymentEnvironment="+"$environment"+ $additionalVariables
& $command
This fails with sqlpackage cmdlet not found. I tried putting the entire exe path to command instead of using alias which didnt change the outcome as well.
I also tried Invoke-Command
, Invoke-Item
and Invoke-Expression
, all failed to run as well. I am thinking like bash script which might be my downfall.
What should I do to make this command work?
It needs to be dynamic since the variables are changing according to the source files.