[string]$MyInvocationPath = $MyInvocation.MyCommand.Path

if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
    if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
        $CommandLine = "-File `"" + $MyInvocationPath + "`" " + $MyInvocation.UnboundArguments
        Start-Process -FilePath PowerShell.exe -Verb RunAs -ArgumentList $CommandLine
        Exit
    }
}

[string]$InstallationFiles = (Join-Path $PSScriptRoot "bin" | Resolve-Path).Path


$targetScript = Join-Path $InstallationFiles "\install\InstallationScript.ps1"

Clear-Host
Write-Host "Running '$targetScript'..." -ForegroundColor Cyan
Write-Host ""
$scriptArgs = @{
    SourcePath = (Resolve-Path $InstallationFiles).Path
}

& $targetScript @scriptArgs

if ($?)
{
    Write-Host "`nSuccesfully installed." -ForegroundColor Green
}

Write-Host ""
Write-Host "Installation finished. Press any key to exit..."
if ($Host.Name -eq 'ConsoleHost') {
    $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
} else {
    Write-Host "Press Enter to exit..."
    Read-Host
}