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

Comments

Projects
None yet
1 participant
@johlju
Collaborator

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 self-assigned this Jan 1, 2017

@johlju

This comment has been minimized.

Collaborator

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 closed this in #280 Jan 5, 2017

@johlju johlju removed their assignment Apr 16, 2017

@johlju johlju removed the in progress label Apr 16, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment