ProductivityTools.GetBinaryModuleFileList.psm1

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

# Laste element cannot have , comma after
function Get-BinaryModuleList {

    [cmdletbinding()]
    param(
        [string]$Directory = (Get-Location).Path
    )
    Write-Verbose "Hello"
    Write-Verbose "Directory: $Directory"

    $items = Get-ChildItem $Directory
    $beforeLast=$($items.Length-2)
    $itemsWithoutLast=$items[0..$beforeLast];
    $lastElement=$items[-1]
    Write-Output "FileList=@("
    
    foreach ($item in $itemsWithoutLast) {
        Write-Output "'$($item.Name)',"
    }
    Write-Output "'$($lastElement.Name)'"
    Write-Output ")"
}

Export-ModuleMember  Get-BinaryModuleList