Closed
Description
Consider a file named, test1.ps1, with the following content.
Configuration SomeNode
{
Import-DscResource -ModuleName xActiveDirectory
Node "NodeName" {
xADDomain "DomainController"
{
DomainName = "DomainName"
DomainAdministratorCredential = "Credential"
SafemodeAdministratorPassword = "password"
}
}
}
PS>Invoke-ScriptAnalyzer -Path c:\tmp\test1.ps1
Invoke-ScriptAnalyzer : Parse error in file c:\tmp\test1.ps1: Could not find the module 'xActiveDirectory' at line 3 column 5.
At line:1 char:1
+ Invoke-ScriptAnalyzer -Path c:\tmp\test1.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ParserError: (ModuleNotFoundDuringParse:String) [Invoke-ScriptAnalyzer], ParseException
+ FullyQualifiedErrorId : Parse error in file c:\tmp\test1.ps1: Could not find the module 'xActiveDirectory' at line 3 column 5.,Microsoft.Windows.PowerShell.ScriptAna
lyzer.Commands.InvokeScriptAnalyzerCommand
Invoke-ScriptAnalyzer : Parse error in file c:\tmp\test1.ps1: Undefined DSC resource 'xADDomain'. Use Import-DSCResource to import the resource at line 5 column 9.
At line:1 char:1
+ Invoke-ScriptAnalyzer -Path c:\tmp\test1.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ParserError: (ResourceNotDefined:String) [Invoke-ScriptAnalyzer], ParseException
+ FullyQualifiedErrorId : Parse error in file c:\tmp\test1.ps1: Undefined DSC resource 'xADDomain'. Use Import-DSCResource to import the resource at line 5 column 9.,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand
This happens because powershell parser cannot find the relevant symbols. However, if the module xActiveDirectory were to be in PSModulePath, the parser wouldn't throw this error.