Closed Susanthab closed 4 years ago
Hi @Susanthab - can you share the CreateSqlFolder.ps1 and ConfigData.psd1 (if they contain no sensitive information)?
Configuration CreateSqlFolder {
Import-DscResource -ModuleName PSDesiredStateConfiguration
Node "localhost" {
File CreateDataDir {
DestinationPath = $ConfigurationData.NonNodeData.DataDir
Ensure = 'Present'
Type = 'Directory'
}
File CreateLogDir {
DestinationPath = $ConfigurationData.NonNodeData.LogDir
Ensure = 'Present'
Type = 'Directory'
}
}
}
.\CreateSqlFolder -Output .\Output\ -ConfigurationData .\SqlServer_ConfigData.psd1
--ConfigData.psd1
@{ AllNodes = @( @{ NodeName = "DSCSVR1" Environment = "Test" } ) NonNodeData = @{ DataDir = "C:\SQL2019\SQLData\" LogDir = "C:\SQL2019\SQLLogs\" TestDir = "C:\Test" } }
Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10
From: Daniel Scott-Raynsford notifications@github.com Sent: Monday, October 14, 2019 9:50:39 PM To: PowerShell/DscResources DscResources@noreply.github.com Cc: Susantha Bathige bathige@hotmail.com; Mention mention@noreply.github.com Subject: Re: [PowerShell/DscResources] Powershell DSC does not work (#533)
Hi @Susanthabhttps://github.com/Susanthab - can you share the CreateSqlFolder.ps1 and ConfigData.psd1 (if they contain no sensitive information)?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/PowerShell/DscResources/issues/533?email_source=notifications&email_token=ADZ23TIXLULS2JZOSRY5DNLQOU4Y7A5CNFSM4JAVWW32YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBHKCXY#issuecomment-542024031, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADZ23TKRC2L67N7HFV4TFXDQOU4Y7ANCNFSM4JAVWW3Q.
If the script continue to run for sometime (10, 15 mins), it errored out with the error below; The script failed due to call depth overflow.
Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10
From: Susantha Bathige Sent: Monday, October 14, 2019 9:54:03 PM To: PowerShell/DscResources reply@reply.github.com; PowerShell/DscResources DscResources@noreply.github.com Cc: Mention mention@noreply.github.com Subject: RE: [PowerShell/DscResources] Powershell DSC does not work (#533)
Configuration CreateSqlFolder {
Import-DscResource -ModuleName PSDesiredStateConfiguration
Node "localhost" {
File CreateDataDir {
DestinationPath = $ConfigurationData.NonNodeData.DataDir
Ensure = 'Present'
Type = 'Directory'
}
File CreateLogDir {
DestinationPath = $ConfigurationData.NonNodeData.LogDir
Ensure = 'Present'
Type = 'Directory'
}
}
}
.\CreateSqlFolder -Output .\Output\ -ConfigurationData .\SqlServer_ConfigData.psd1
--ConfigData.psd1
@{ AllNodes = @( @{ NodeName = "DSCSVR1" Environment = "Test" } ) NonNodeData = @{ DataDir = "C:\SQL2019\SQLData\" LogDir = "C:\SQL2019\SQLLogs\" TestDir = "C:\Test" } }
Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10
From: Daniel Scott-Raynsford notifications@github.com Sent: Monday, October 14, 2019 9:50:39 PM To: PowerShell/DscResources DscResources@noreply.github.com Cc: Susantha Bathige bathige@hotmail.com; Mention mention@noreply.github.com Subject: Re: [PowerShell/DscResources] Powershell DSC does not work (#533)
Hi @Susanthabhttps://github.com/Susanthab - can you share the CreateSqlFolder.ps1 and ConfigData.psd1 (if they contain no sensitive information)?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/PowerShell/DscResources/issues/533?email_source=notifications&email_token=ADZ23TIXLULS2JZOSRY5DNLQOU4Y7A5CNFSM4JAVWW32YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBHKCXY#issuecomment-542024031, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADZ23TKRC2L67N7HFV4TFXDQOU4Y7ANCNFSM4JAVWW3Q.
Hi @Susanthab, I've figured out what is going on here: You're calling your script from within the script you're calling - this is going into an infinite loop. You should be calling the DSC Config defined in your script.
Remove the .\ from the beginning of the .\CreateSqlFolder -Output .\Output\ -ConfigurationData .\SqlServer_ConfigData.psd1
line.
E.g.
Configuration CreateSqlFolder {
Import-DscResource -ModuleName PSDesiredStateConfiguration
Node "localhost" {
File CreateDataDir {
DestinationPath = $ConfigurationData.NonNodeData.DataDir
Ensure = 'Present'
Type = 'Directory'
}
File CreateLogDir {
DestinationPath = $ConfigurationData.NonNodeData.LogDir
Ensure = 'Present'
Type = 'Directory'
}
}
}
CreateSqlFolder -Output .\Output\ -ConfigurationData .\SqlServer_ConfigData.psd1
@Daniel thanks for the reply. This is what confuses me. I’m using the vscode and when I remove the “.\” then highlight the text and run it, it gives me the error below;
Suggestion [3,General]: The command CreateSqlFolder was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\CreateSqlFolder". See "get-help about_Command_Precedence" for more details.
That is what I had to use “.\” with the file name. However, if I run the command as you mentioned directly in the terminal then it works. I think vscode has some issue in here.
Thanks.
From: Daniel Scott-Raynsford notifications@github.com Sent: Friday, October 18, 2019 2:29:27 PM To: PowerShell/DscResources DscResources@noreply.github.com Cc: Susantha Bathige bathige@hotmail.com; Mention mention@noreply.github.com Subject: Re: [PowerShell/DscResources] Powershell DSC does not work (#533)
Hi @Susanthabhttps://github.com/Susanthab, I've figured out what is going on here: You're calling your script from within the script you're calling - this is going into an infinite loop. You should be calling the DSC Config defined in your script.
Remove the .\ from the beginning of the .\CreateSqlFolder -Output .\Output\ -ConfigurationData .\SqlServer_ConfigData.psd1 line.
E.g.
Configuration CreateSqlFolder {
Import-DscResource -ModuleName PSDesiredStateConfiguration
Node "localhost" {
File CreateDataDir {
DestinationPath = $ConfigurationData.NonNodeData.DataDir
Ensure = 'Present'
Type = 'Directory'
}
File CreateLogDir {
DestinationPath = $ConfigurationData.NonNodeData.LogDir
Ensure = 'Present'
Type = 'Directory'
}
}
}
CreateSqlFolder -Output .\Output\ -ConfigurationData .\SqlServer_ConfigData.psd1
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/PowerShell/DscResources/issues/533?email_source=notifications&email_token=ADZ23TONFDYNB6HJ5LMZUPTQPIMCPA5CNFSM4JAVWW32YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBV3CIA#issuecomment-543928608, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADZ23TKSVCBRJTUCAVVW7YTQPIMCPANCNFSM4JAVWW3Q.
If this has been resolved, could you close the issue? (And maybe file an issue in the vscode-powershell extension if it still exists in the current version.)
I will reopen the issue if I observed it again. Thanks for the follow-up.
Powershell version is 5.1.17763.771 and Windows version is 1809 (OS Build 17763.805) I'm trying to run simple configuration file to create a dir. The script keeps running no output produced. No MOF file generated.
Example: .\CreateSqlFolder -Output .\Output\ -ConfigurationData .\ConfigData.psd1