Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xSQLServerScript: Fails when calling Invoke-Sqlcmd using PowerShell 4.0 from LCM #273

Closed
johlju opened this issue Dec 30, 2016 · 1 comment · Fixed by #280
Closed

xSQLServerScript: Fails when calling Invoke-Sqlcmd using PowerShell 4.0 from LCM #273

johlju opened this issue Dec 30, 2016 · 1 comment · Fixed by #280
Labels
bug The issue is a bug.

Comments

@johlju
Copy link
Member

johlju commented Dec 30, 2016

Details of the scenario you try and problem that is occurring:
When PowerShell 4,0 is installed calling Invoke-Sqlcmd from the helper function Invoke-SqlScript fails.
See more detailed explanation here:
#252 (comment)

If there is no solution to running this resource using PowerShell 4.0, then as a minimum we have to document in the README.md that this is PowerShell 5.0 only.

The DSC configuration that is using the resource (as detailed as possible):
Configuration

xSQLServerScript 'SQL2014-RunSQLScript'
{
    ServerInstance = 'sqltest3.company.local\SQL2014'
    SetFilePath = 'C:\DSCTemp\SQLScripts\Set-RunSQLScript.sql'
    TestFilePath = 'C:\DSCTemp\SQLScripts\Test-RunSQLScript.sql'
    GetFilePath = 'C:\DSCTemp\SQLScripts\Get-RunSQLScript.sql'
}  

Get-RunSQLScript.sql

select name from sys.databases where name = 'MyScriptDatabase1'

Set-RunSQLScript.sql

CREATE DATABASE [MyScriptDatabase1]

Test-RunSQLScript.sql

if (select count(name) from sys.databases where name = 'MyScriptDatabase1') = 0
BEGIN
	RAISERROR ('Did not find database [MyScriptDatabase1]', 16, 1)
END
ELSE
BEGIN
	PRINT 'Found database [MyScriptDatabase1]'
END

Version of the Operating System, SQL Server and PowerShell the DSC Target Node is running:
Windows Server 2012 R2, SQL Server 2014, PowerShell 4.0

Version of the DSC module you're using, or 'dev' if you're using current dev branch:
Dev

@johlju johlju added bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community. in progress The issue is being actively worked on by someone. and removed help wanted The issue is up for grabs for anyone in the community. labels Dec 30, 2016
@johlju johlju self-assigned this Jan 1, 2017
@johlju
Copy link
Member Author

johlju commented Jan 1, 2017

For the time being I will put a note in the README.md that there is a known problem running the xSQLServerScript resource using PowerShell 4.0.

@johlju johlju removed their assignment Apr 16, 2017
@johlju johlju removed the in progress The issue is being actively worked on by someone. label Apr 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant