#requires -RunAsAdministrator
function Invoke-TunerQuickSetup {
        Quick configuration with default parameters
        Quick configuration of Windows machine based on user roles like
        Basic, AppDev, AppDevPro, SysAdmin, and Consultant. Invokes the other
        functions to cleanup, configure and so forth.
    .PARAMETER Configuration
        User role-based configuration template: Basic (default), AppDev, AppDevPro,
        SysAdmin and Consultant. Controls the chocolatey packages that get installed
        and additional PowerShell modules that will be installed.
    .PARAMETER ConfigurationsPath
        Custom path to configuration .txt files (basic.txt, appdev.txt, etc.)
    .PARAMETER NewName
        New computer name to apply (forces restart at the end)
        Install and enable sysinternals bginfo desktop mod
    .PARAMETER TimeZone
        Set timezone (default: Eastern Standard Time)
    .PARAMETER SkipCleanup
        Skip Appx cleanup
    .PARAMETER SkipModules
        Skip installing or updating powershell modules list
    .PARAMETER SkipUpdates
        Skip installing windows updates
    .PARAMETER SkipChoco
        Skip installing or updating chocolatey packages
    .PARAMETER SkipTimeZone
        Skip setting the active time zone (otherwise -TimeZone is applied)
    .PARAMETER ForceRestart
        Forces the computer to restart at the very end of processing
        Installs and configures all defaults without renaming computer or installing BGinfo mod
        Invoke-TunerQuickSetup -Configuration AppDev -NewName "Client3"
        Installs chocolatey packages for 'appdev' user and renames computer to Client3
        Invoke-TunerQuickSetup -Configuration SysAdmin -BGInfo
        Installs default chocolatey packages and Sysinternals BGinfo with default options
        Invoke-TunerQuickSetup -Configuration SysAdmin -NewName "Client3" -BGInfo
        Installs chocolatey packages for 'sysadmin' user, renames computer to Client3 and installs Sysinternals BGInfo
        Invoke-TunerQuickSetup -Configuration Consultant -SkipCleanup -SkipModules -SkipUpdates
        Installs default chocolatey packages for 'consultant' user, skips Appx cleanup, PS modules and patching
        Invoke-TunerQuickSetup -Configuration AppDevPro -BGInfo
        Invoke-TunerQuickSetup -NewName "Client3" -BGInfo -SkipCleanup -SkipModules -SkipUpdates
        Installs default default chocolatey packages, renames computer to Client3, installs BGInfo,
        skips Appx cleanup, PS modules and patching
        Invoke-TunerQuickSetup -Configuration Basic -BGInfo -TimeZone 'Central Standard Time'
        Invoke-TunerQuickSetup -Configuration SysAdmin -ConfigurationsPath "x:\configfiles" -BGInfo -NewName "W10-TEST" -ForceRestart
        Installs default chocolatey packages for 'sysadmin' user from custom location x:\configfiles, installs BGInfo,
        renames computer to W10-TEST and forces a restart at the end

    param (
        [parameter(Mandatory=$False, HelpMessage="Tuner setup configuration")]
            [string] $Configuration = "Basic",
        [parameter(Mandatory=$False, HelpMessage="Path to custom configuration files")]
            [string] $ConfigurationsPath = "",
        [parameter(Mandatory=$False, HelpMessage="New computer name")]
            [string] $NewName = "",
            [string] $TimeZone = 'Eastern Standard Time',
        [parameter(Mandatory=$False, HelpMessage="Install and enable BGInfo profile")]
            [switch] $BGInfo,
        [parameter(Mandatory=$False, HelpMessage="Skip Appx clean-up")]
            [switch] $SkipCleanup,
        [parameter(Mandatory=$False, HelpMessage="Skip installing PowerShell modules")]
            [switch] $SkipModules,
        [parameter(Mandatory=$False, HelpMessage="Skip Windows updates")]
            [switch] $SkipUpdates,
        [parameter(Mandatory=$False, HelpMessage="Skip Chocolatey package installations")]
            [switch] $SkipChoco,
        [parameter(Mandatory=$False, HelpMessage="Skip time zone configuration")]
            [switch] $SkipTimeZone,
        [parameter(Mandatory=$False, HelpMessage="Force a restart when finished")]
            [switch] $ForceRestart
    Start-Transcript -Path $env:USERPROFILE\documents\turbosetup_transcript.txt
    $regpath = "HKCU:Software\Tuner"
    try {
        $time1 = (Get-Date)
        if (!$SkipCleanup) { 
            # call without -GridSelect option for fast-mode processing
        if (!$SkipChoco)   { 
            Install-TunerChocoPackages -Path $ConfigurationsPath -FileName "$Configuration.txt"
        if (!$SkipModules) { 
            Invoke-TunerPSModules -Name ('azurerm','powerline','dbatools','carbon','platyps','pswindowsupdate','osbuilder') 
        if (!$SkipUpdates) { 
        if ($BGInfo) { 
        if (!$SkipTimeZone) {
            Set-TunerTimeZone -TimeZone $TimeZone
        if (![string]::IsNullOrEmpty($NewName)) {
            Write-Host "renaming computer to $NewName" -ForegroundColor Magenta
            Rename-Computer -NewName $NewName -Force
            $restart = $True
            Write-Host "restart will be invoked at the end." -ForegroundColor Magenta
        $time2 = (Get-Date)
        $rtime = [math]::Round((New-TimeSpan -Start $time1 -End $time2).TotalMinutes,2)
        New-ItemProperty -Path $regpath -Name "ConfigurationName" -Value $Configuration -Force
        New-ItemProperty -Path $regpath -Name "TimeZone" -Value $TimeZone -Force
        New-ItemProperty -Path $regpath -Name "LastRun" -Value (Get-Date) -Force
        Write-Host "total runtime: $rtime minutes" -ForegroundColor Green
    catch {}
    finally { 
        if ($ForceRestart -or ($restart -eq $True)) { Restart-Computer -Force }

Export-ModuleMember -Function Invoke-TunerQuickSetup