Skip to content

Instantly share code, notes, and snippets.

@bgelens
Created October 24, 2016 19:55
Show Gist options
  • Save bgelens/1246ac64ffbb7518597f6e71137c301c to your computer and use it in GitHub Desktop.
Save bgelens/1246ac64ffbb7518597f6e71137c301c to your computer and use it in GitHub Desktop.
function Test-ClassResource
{
param(
[Parameter(ValueFromPipeline=$True,Mandatory=$True)]
[string]$fileName
)
$ast = [System.Management.Automation.Language.Parser]::ParseFile($fileName, [ref]$null, [ref]$null)
$result = foreach ($item in $ast.FindAll({$args[0] -is [System.Management.Automation.Language.AttributeAst]}, $false))
{
if ($item.Extent.Text -eq '[DscResource()]')
{
$true
}
}
if ($result)
{
$true
}
else
{
$false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment