Public/Start-P1TenantManager.ps1

function Start-P1TenantManager {

[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
# Height="241" Width="498" @''@
 
[xml]$xaml = Get-Content "$PSScriptRoot\MainWindow.xaml"

$reader=(New-Object System.Xml.XmlNodeReader $xaml)
try {
    $Form=[Windows.Markup.XamlReader]::Load( $reader )
} catch {
    Write-Host "Unable to load Windows.Markup.XamlReader. Double-check syntax and ensure .net is installed."
}

#===========================================================================
# Store Form Objects In PowerShell
#===========================================================================
$xaml.SelectNodes("//*[@Name]") | %{Set-Variable -Name ($_.Name) -Value $Form.FindName($_.Name)}

#===========================================================================
# Add events to Form Objects
#===========================================================================
$btnExit.Add_Click({$form.Close()})
$btnTest.Add_Click({
    $features = Test-P1Prerequisites
    $prereqDataGrid.ItemsSource = @($features)
})

$btnAddMissing.Add_Click({
    $features = Test-P1Prerequisites -Install
    $prereqDataGrid.ItemsSource = @($features)
})


$Form.ShowDialog() | out-null    
}