Functions/Public/Get/Get-WindowsArtifact.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function Get-WindowsArtifact {

    <#
 
    .SYNOPSIS
    Returns a list of supported artifacts for discovery in a Windows image.
     
    .EXAMPLE
 
    $Artifacts = Get-WindowsArtifact
 
    This will return all of the discoverable artifacts and assign the result to the Artifacts Variable
     
    #>

    [CmdletBinding()]
    param (
    )

    $ArtifactList = Get-ChildItem -Path $ModulePath\Functions\Private\Artifacts -Directory
    Write-Verbose -Message ('Searching for artifacts in filesystem path: {0}\Artifacts' -f $ModulePath)
    
    foreach ($Artifact in $ArtifactList) {
        $ChildItems = (Get-ChildItem -Path $Artifact.FullName).Name
        Write-Verbose -Message ('Child items for "{0}" artifact: {1}' -f $Artifact.FullName, ($ChildItems -join ', '))

        if ($ChildItems -contains "Discover_$Artifact.ps1" -and $ChildItems -contains "Generate_$Artifact.ps1") {
            Write-Output -InputObject $Artifact.Name
            Write-Verbose -Message ('Valid artifact found: {0}' -f $Artifact.Name)
        }
    }

}