CmdLets/Library/Install-LibraryApplication.ps1

Function Install-LibraryApplication 
 {

    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$True,ValueFromPipeline=$True)]
            $Application,
        [Parameter(Mandatory=$True)]
            [System.IO.FileInfo]$Path
    )
    Begin {
        
    }
    Process{
        ForEach ($App in $Application) {
            Write-Host "Installing: $($App.Name)"
            ForEach ($Item in $App.Install) {
                #This Replace is here while the Json contains both Relative paths and not, the goal is to have relative paths
                $Item.Path = $Item.Path.Replace("[SoftwarePath]",$Path).Replace("[Name]",$App.Name).Replace("\\","")
                $Item.Arguments = $Item.Arguments.Replace("[SoftwarePath]",$Path).Replace("[Name]",$App.Name).Replace("\\","")
                #The above line assumes relative and NON-UNC paths, so replace \\ with \

                ForEach ($ScriptBlock in $Item.PreScriptBlocks) { 
                    Write-Verbose "Executing: $Scriptblock"
                    Invoke-Command -ScriptBlock ([ScriptBlock]::Create($ScriptBlock)) -NoNewScope 
                }

                If ($Item.Path){
                    $Files = Get-ChildItem $Item.Path -Recurse:$Item.Recurse
                }

                ForEach($File in $Files) {
                    Write-Host "'t$($File.Name)"
                    If ($Item.Arguments) {
                        $Process = Start-Process -FilePath $File.FullName -ArgumentList "$($Item.Arguments)" -PassThru
                    } else {
                        $Process = Start-Process -FilePath $File.Fullname -PassThru
                    }

                    Watch-Process -Process $Process
                    Start-Sleep -Seconds 1
                }

                ForEach ($ScriptBlock in $Item.PostScriptBlocks) { 
                    Write-Verbose "Executing: $Scriptblock"
                    Invoke-Command -ScriptBlock ([ScriptBlock]::Create($ScriptBlock)) -NoNewScope
                }
            }
        }
    }
    End{
    }

}