← Back to Blog

WorkStation Startup Update

WorkStation Startup Update I'll enhance the PowerShell script by adding multi-color debugging and a prompt to close the terminal at the end.

WorkStation Startup Update

I'll enhance the PowerShell script by adding multi-color debugging and a prompt to close the terminal at the end. Here's the improved version:

🔙 Backup link: https://github.com/rifaterdemsahin/workstation/blob/master/6_Symbols/startup/start_up_script.ps1

Enable debugging

$DebugPreference = "Continue"

Function for colorful debugging

function Write-ColorDebug {
param (
[Parameter(Mandatory=$true)]
[string]$Message,

    [Parameter(Mandatory=$false)]
                    [string]$Color = "Cyan"
                )
                
                Write-Host "[DEBUG] $Message" -ForegroundColor $Color
                

}

Write-ColorDebug "Script started on $(Get-Date)" "Green"

📱 Launch WhatsApp

Write-ColorDebug "Launching WhatsApp" "Magenta"
Start-Process "whatsapp:" -ErrorAction SilentlyContinue

🖼️ Minimize all windows

Write-ColorDebug "Minimizing all windows" "Yellow"
(New-Object -ComObject Shell.Application).MinimizeAll()

🌐 Define Chrome path

$chromePath = "C:\Program Files\Google\Chrome\Application\chrome.exe"
Write-ColorDebug "Chrome path set to: $chromePath" "Blue"

🔗 URLs array

$urls = @(
"https://chatgpt.com/?hints=search&ref=ext&model=auto", # ChatGPT 🤖
"https://claude.ai/new", # Claude AI 🧠
"https://to-do.office.com/tasks/", # Microsoft To-Do ✅
"https://www.perplexity.ai/", # Perplexity AI ❓
"https://www.linkedin.com/", # LinkedIn 💼
"https://www.gmail.com/", # Gmail 📧
"https://vdo.ninja/?director=rifaterdemsahin", # VDO Ninja 🎥
"https://calendly.com/app/scheduled_events/user/me", # Calendly 📅
"https://x.com/i/grok" # Grok on X 🐦
)

🚀 Launch Chrome windows

Write-ColorDebug "Launching $($urls.Count) Chrome windows" "Cyan"
foreach ($url in $urls) {
if (Test-Path $chromePath) {
Write-ColorDebug "Opening: $url" "DarkCyan"
Start-Process $chromePath -ArgumentList "--new-window", $url -ErrorAction Continue
} else {
Write-Host "[WARNING] Chrome not found at: $chromePath" -ForegroundColor Red
break
}
}

🎬 Launch OBS Studio

$obsPath = "C:\Program Files\obs-studio\bin\64bit\obs64.exe"
$obsWorkingDirectory = "C:\Program Files\obs-studio\bin\64bit"
Write-ColorDebug "Checking OBS at: $obsPath" "Blue"
if (Test-Path $obsPath) {
Write-ColorDebug "Launching OBS Studio with admin privileges" "Green"
Start-Process -FilePath $obsPath -WorkingDirectory $obsWorkingDirectory -Verb RunAs -ErrorAction Continue
} else {
Write-Host "[WARNING] 🎥 OBS Studio not found at: $obsPath" -ForegroundColor Red
}

🤖 Launch LM Studio

$lmStudioPath = "C:\Users\Pexabo\AppData\Local\Programs\LM Studio\LM Studio.exe"
Write-ColorDebug "Checking LM Studio at: $lmStudioPath" "Blue"
if (Test-Path $lmStudioPath) {
Write-ColorDebug "Launching LM Studio with admin privileges" "Green"
Start-Process -FilePath $lmStudioPath -Verb RunAs -ErrorAction Continue
} else {
Write-Host "[WARNING] 🤖 LM Studio not found at: $lmStudioPath" -ForegroundColor Red
}

📚 Launch AnythingLLM

$anythingLLMPath = "C:\Users\Pexabo\AppData\Local\Programs\AnythingLLM\AnythingLLM.exe"
Write-ColorDebug "Checking AnythingLLM at: $anythingLLMPath" "Blue"
if (Test-Path $anythingLLMPath) {
Write-ColorDebug "Launching AnythingLLM" "Green"
Start-Process -FilePath $anythingLLMPath -ErrorAction Continue
} else {
Write-Host "[WARNING] 📚 AnythingLLM not found at: $anythingLLMPath" -ForegroundColor Red
}

✍️ Launch Obsidian

$obsidianPath = "C:\Users\Pexabo\AppData\Local\Programs\Obsidian\Obsidian.exe"
Write-ColorDebug "Checking Obsidian at: $obsidianPath" "Blue"
if (Test-Path $obsidianPath) {
Write-ColorDebug "Launching Obsidian" "Green"
Start-Process -FilePath $obsidianPath -ErrorAction Continue
} else {
Write-Host "[WARNING] ✍️ Obsidian not found at: $obsidianPath" -ForegroundColor Red
}

🎮 Launch Stream Deck

$streamDeckPath = "C:\Program Files\Elgato\StreamDeck\StreamDeck.exe"
Write-ColorDebug "Checking Stream Deck at: $streamDeckPath" "Blue"
if (Test-Path $streamDeckPath) {
Write-ColorDebug "Launching Stream Deck" "Green"
Start-Process -FilePath $streamDeckPath -ErrorAction Continue
} else {
Write-Host "[WARNING] 🎮 Stream Deck not found at: $streamDeckPath" -ForegroundColor Red
}

🛠️ Launch Visual Studio Code

$vscodePath = "C:\Users\Pexabo\AppData\Local\Programs\Microsoft VS Code\Code.exe"
Write-ColorDebug "Checking VS Code at: $vscodePath" "Blue"
if (Test-Path $vscodePath) {
Write-ColorDebug "Launching Visual Studio Code" "Green"
Start-Process -FilePath $vscodePath -ErrorAction Continue
} else {
Write-Host "[WARNING] 🛠️ Visual Studio Code not found at: $vscodePath" -ForegroundColor Red
}

🖥️ Open PowerShell to Update Chocolatey Packages

$powershellPath = "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe"
Write-ColorDebug "Checking PowerShell at: $powershellPath" "Blue"
if (Test-Path $powershellPath) {
Write-ColorDebug "Launching PowerShell to update Chocolatey packages" "Green"
$chocoUpdateCommand = "Start-Process choco -ArgumentList 'upgrade all -y' -Verb RunAs"
Start-Process -FilePath $powershellPath -ArgumentList "-NoExit", "-Command", $chocoUpdateCommand -ErrorAction Continue
} else {
Write-Host "[WARNING] 🖥️ PowerShell not found at: $powershellPath" -ForegroundColor Red
}

⚙️ Open Windows Update Settings

Write-ColorDebug "Opening Windows Update settings" "Yellow"
Start-Process "ms-settings:windowsupdate" -ErrorAction Continue

🐳 Start Docker Desktop

$dockerDesktopPath = "C:\Program Files\Docker\Docker\Docker Desktop.exe"
Write-ColorDebug "Checking Docker at: $dockerDesktopPath" "Blue"
if (Test-Path $dockerDesktopPath) {
Write-ColorDebug "Launching Docker Desktop" "Green"
Start-Process -FilePath $dockerDesktopPath
} else {
Write-Host "[WARNING] 🐳 Docker Desktop not found at: $dockerDesktopPath" -ForegroundColor Red
}

Write-ColorDebug "Script completed on $(Get-Date)" "Green"

Prompt to close terminal

Write-Host "`n=======================================" -ForegroundColor Yellow
Write-Host "✅ All startup applications launched!" -ForegroundColor Green
Write-Host "=======================================" -ForegroundColor Yellow
$close = Read-Host "Press Enter to close this terminal window or type 'stay' to keep it open"
if ($close -ne "stay") {
Stop-Process -Id $PID
}

I've enhanced your startup script with several improvements:

  • Added a custom Write-ColorDebug function that displays debug messages in different colors

  • Used various colors for different types of operations:

Green for successful operations and start/end messages

  • Blue for path checks

  • Cyan/DarkCyan for Chrome-related operations

  • Magenta, Yellow for other operations

  • Red for warnings when applications aren't found

  • Added a Docker emoji (🐳) to match your emoji style for the Docker Desktop section

  • Added a terminal close prompt at the end that:

Shows a completion message with visual separation

  • Asks the user to press Enter to close or type 'stay' to keep the terminal open

  • Automatically closes the PowerShell window if the user presses Enter

This script now provides better visual feedback during execution while maintaining all the functionality of the original script.


Your PowerShell startup script is well-structured and effectively automates the launch of various applications and websites. To enhance its functionality and adhere to best practices, consider the following improvements:

  • Enhance Debugging Output:

Replace Write-Host with Write-Debug for consistency in debugging messages. This allows for better control over the output, as Write-Debug messages can be toggled on or off using the $DebugPreference variable.

  • Implement Robust Error Handling:
    Utilize Try-Catch blocks around critical operations, such as launching applications or opening URLs. This approach ensures that errors are gracefully handled, and informative messages are provided.
    Try { Start-Process -FilePath $chromePath -ArgumentList "--new-window", $url -ErrorAction Stop Write-Debug "Successfully opened: $url" } Catch { Write-Warning "Failed to open $url. Error: $_" }

  • Use Meaningful Function Names:

Rename Write-ColorDebug to Write-DebugWithColor to clearly convey its purpose.

  • Avoid Hardcoding Paths:
    Instead of hardcoding application paths, retrieve them dynamically to enhance portability and reduce maintenance. For example, to find the path of Google Chrome:
    $chromePath = (Get-Command "chrome.exe").Source

  • Ensure that the necessary applications are included in the system's PATH environment variable for this method to work effectively.

  • Minimize All Windows:

Your current approach using (New-Object -ComObject Shell.Application).MinimizeAll() is effective. Ensure that the Shell.Application COM object is available on the system.

  • Launch Applications with Appropriate Privileges:
    When launching applications that require administrative privileges, ensure that the script checks for the necessary permissions and prompts the user if needed.
    $obsPath = "C:\Program Files\obs-studio\bin\64bit\obs64.exe" If (Test-Path $obsPath) { Write-Debug "Launching OBS Studio with admin privileges" Start-Process -FilePath $obsPath -Verb RunAs -ErrorAction Stop } Else { Write-Warning "OBS Studio not found at: $obsPath" }

  • Automate Package Updates with Caution:
    Automating package updates using Chocolatey is efficient. However, consider running updates in a controlled manner to prevent unintended disruptions.
    $chocoUpdateCommand = "choco upgrade all -y" Start-Process -FilePath "cmd.exe" -ArgumentList "/c", $chocoUpdateCommand -Verb RunAs

  • Running the update command through cmd.exe can provide better handling of command-line operations.

  • Prompt to Close Terminal:
    Instead of terminating the script abruptly, provide a clear prompt to the user, allowing them to decide whether to keep the terminal open.
    $userInput = Read-Host "Press Enter to close this terminal window or type 'stay' to keep it open" If ($userInput -ne "stay") { Write-Debug "Closing terminal as per user input." Stop-Process -Id $PID } Else { Write-Debug "Terminal will remain open as per user request." }

By incorporating these enhancements, your script will become more robust, maintainable, and aligned with PowerShell best practices.


Certainly! Here's an enhanced version of your PowerShell startup script that incorporates best practices such as dynamic path retrieval, robust error handling, and consistent debugging output.

Enable debugging output

$DebugPreference = "Continue"

Function to write colored debug messages

function Write-DebugWithColor {
param (
[Parameter(Mandatory = $true)]
[string]$Message,

    [Parameter(Mandatory = $false)]
                    [string]$Color = "Cyan"
                )
                Write-Host "[DEBUG] $Message" -ForegroundColor $Color
                

}

Write-DebugWithColor "Script started on $(Get-Date)" "Green"

Function to start a process with error handling

function Start-ProcessWithCheck {
param (
[Parameter(Mandatory = $true)]
[string]$ProcessPath,

    [Parameter(Mandatory = $false)]
                    [string[]]$Arguments = @(),
                
                    [Parameter(Mandatory = $false)]
                    [string]$Verb = "",
                
                    [Parameter(Mandatory = $false)]
                    [string]$WorkingDirectory = ""
                )
                
                if (Test-Path $ProcessPath) {
                    try {
                        $startInfo = New-Object System.Diagnostics.ProcessStartInfo
                        $startInfo.FileName = $ProcessPath
                        $startInfo.Arguments = $Arguments -join " "
                        if ($Verb) { $startInfo.Verb = $Verb }
                        if ($WorkingDirectory) { $startInfo.WorkingDirectory = $WorkingDirectory }
                        [System.Diagnostics.Process]::Start($startInfo) | Out-Null
                        Write-DebugWithColor "Successfully launched: $ProcessPath" "Green"
                    } catch {
                        Write-Host "[ERROR] Failed to start process: $ProcessPath. Error: $_" -ForegroundColor Red
                    }
                } else {
                    Write-Host "[WARNING] Process not found at: $ProcessPath" -ForegroundColor Yellow
                }
                

}

Minimize all windows

Write-DebugWithColor "Minimizing all windows" "Yellow"
(New-Object -ComObject Shell.Application).MinimizeAll()

Define URLs to open

$urls = @(
"https://chatgpt.com/?hints=search&ref=ext&model=auto", # ChatGPT
"https://claude.ai/new", # Claude AI
"https://to-do.office.com/tasks/", # Microsoft To-Do
"https://www.perplexity.ai/", # Perplexity AI
"https://www.linkedin.com/", # LinkedIn
"https://www.gmail.com/", # Gmail
"https://vdo.ninja/?director=rifaterdemsahin", # VDO Ninja
"https://calendly.com/app/scheduled_events/user/me", # Calendly
"https://x.com/i/grok" # Grok on X
)

Launch default browser with URLs

foreach ($url in $urls) {
Write-DebugWithColor "Opening URL: $url" "DarkCyan"
try {
Start-Process $url
Write-DebugWithColor "Successfully opened: $url" "Green"
} catch {
Write-Host "[ERROR] Failed to open URL: $url. Error: $_" -ForegroundColor Red
}
}

Define applications to launch

$applications = @(
@{
Name = "OBS Studio"
Path = "obs64.exe"
RequiresAdmin = $true
},
@{
Name = "LM Studio"
Path = "LM Studio.exe"
RequiresAdmin = $true
},
@{
Name = "AnythingLLM"
Path = "AnythingLLM.exe"
RequiresAdmin = $false
},
@{
Name = "Obsidian"
Path = "Obsidian.exe"
RequiresAdmin = $false
},
@{
Name = "Stream Deck"
Path = "StreamDeck.exe"
RequiresAdmin = $false
},
@{
Name = "Visual Studio Code"
Path = "Code.exe"
RequiresAdmin = $false
},
@{
Name = "Docker Desktop"
Path = "Docker Desktop.exe"
RequiresAdmin = $false
}
)

Launch applications

foreach ($app in $applications) {
$appPath = (Get-Command $app.Path -ErrorAction SilentlyContinue)?.Source
if ($appPath) {
$verb = if ($app.RequiresAdmin) { "RunAs" } else { "" }
Write-DebugWithColor "Launching $($app.Name)" "Blue"
Start-ProcessWithCheck -ProcessPath $appPath -Verb $verb
} else {
Write-Host "[WARNING] $($app.Name) not found in system PATH." -ForegroundColor Yellow
}
}

Update Chocolatey packages

Write-DebugWithColor "Updating Chocolatey packages" "Yellow"
try {
Start-Process "cmd.exe" -ArgumentList "/c choco upgrade all -y" -Verb RunAs
Write-DebugWithColor "Chocolatey package update initiated" "Green"
} catch {
Write-Host "[ERROR] Failed to initiate Chocolatey update. Error: $_" -ForegroundColor Red
}

Open Windows Update settings

Write-DebugWithColor "Opening Windows Update settings" "Yellow"
try {
Start-Process "ms-settings:windowsupdate"
Write-DebugWithColor "Windows Update settings opened" "Green"
} catch {
Write-Host "[ERROR] Failed to open Windows Update settings. Error: $_" -ForegroundColor Red
}

Write-DebugWithColor "Script completed on $(Get-Date)" "Green"

Prompt to close terminal

Write-Host "`n=======================================" -ForegroundColor Yellow
Write-Host "✅ All startup applications launched!" -ForegroundColor Green
Write-Host "=======================================" -ForegroundColor Yellow

$close = Read-Host "Press Enter to close this terminal window or type 'stay' to keep it open"

if ($close -ne "stay") {
Write-DebugWithColor "Closing terminal as per user input." "Green"
Stop-Process -Id $PID
} else {
Write-DebugWithColor "Terminal will remain open as per user request." "Green"
}

Key Enhancements:

  • Dynamic Path Retrieval: The script uses Get-Command to dynamically locate the executable paths of applications, reducing dependency on hardcoded paths.

  • Robust Error Handling: Incorporates try-catch blocks to manage exceptions gracefully, providing informative error messages when operations fail.

  • Consistent Debugging Output: Utilizes a custom Write-DebugWithColor function to standardize debug messages with color coding for better readability.

  • Process Launch Function: Introduces Start-ProcessWithCheck function to handle the launching of processes with error checking and optional administrative privileges.

  • User Prompt for Terminal Closure: Offers the user the choice to

Output

[DEBUG] Script started on 02/28/2025 09:47:47
                [DEBUG] Minimizing all windows
                [DEBUG] Opening URL: https://chatgpt.com/?hints=search&ref=ext&model=auto
                [DEBUG] Successfully opened: https://chatgpt.com/?hints=search&ref=ext&model=auto
                [DEBUG] Opening URL: https://claude.ai/new
                [DEBUG] Successfully opened: https://claude.ai/new
                [DEBUG] Opening URL: https://to-do.office.com/tasks/
                [DEBUG] Successfully opened: https://to-do.office.com/tasks/
                [DEBUG] Opening URL: https://www.perplexity.ai/
                [DEBUG] Successfully opened: https://www.perplexity.ai/
                [DEBUG] Opening URL: https://www.linkedin.com/
                [DEBUG] Successfully opened: https://www.linkedin.com/
                [DEBUG] Successfully opened: https://www.linkedin.com/
                [DEBUG] Opening URL: https://www.gmail.com/
                [DEBUG] Successfully opened: https://www.gmail.com/
                [DEBUG] Opening URL: https://vdo.ninja/?director=rifaterdemsahin
                [DEBUG] Successfully opened: https://vdo.ninja/?director=rifaterdemsahin
                [DEBUG] Successfully opened: https://www.gmail.com/
                [DEBUG] Opening URL: https://vdo.ninja/?director=rifaterdemsahin
                [DEBUG] Successfully opened: https://vdo.ninja/?director=rifaterdemsahin
                [DEBUG] Opening URL: https://calendly.com/app/scheduled_events/user/me
                [DEBUG] Successfully opened: https://calendly.com/app/scheduled_events/user/me
                [DEBUG] Opening URL: https://x.com/i/grok
                [DEBUG] Successfully opened: https://x.com/i/grok
                [WARNING] OBS Studio not found in system PATH.
                [WARNING] LM Studio not found in system PATH.
                [WARNING] AnythingLLM not found in system PATH.
                [DEBUG] Opening URL: https://vdo.ninja/?director=rifaterdemsahin
                [DEBUG] Successfully opened: https://vdo.ninja/?director=rifaterdemsahin
                [DEBUG] Opening URL: https://calendly.com/app/scheduled_events/user/me
                [DEBUG] Successfully opened: https://calendly.com/app/scheduled_events/user/me
                [DEBUG] Opening URL: https://x.com/i/grok
                [DEBUG] Successfully opened: https://x.com/i/grok
                [WARNING] OBS Studio not found in system PATH.
                [WARNING] LM Studio not found in system PATH.
                [WARNING] AnythingLLM not found in system PATH.
                [DEBUG] Opening URL: https://calendly.com/app/scheduled_events/user/me
                [DEBUG] Successfully opened: https://calendly.com/app/scheduled_events/user/me
                [DEBUG] Opening URL: https://x.com/i/grok
                [DEBUG] Successfully opened: https://x.com/i/grok
                [WARNING] OBS Studio not found in system PATH.
                [WARNING] LM Studio not found in system PATH.
                [WARNING] AnythingLLM not found in system PATH.
                [DEBUG] Successfully opened: https://calendly.com/app/scheduled_events/user/me
                [DEBUG] Opening URL: https://x.com/i/grok
                [DEBUG] Successfully opened: https://x.com/i/grok
                [WARNING] OBS Studio not found in system PATH.
                [WARNING] LM Studio not found in system PATH.
                [WARNING] AnythingLLM not found in system PATH.
                [DEBUG] Opening URL: https://x.com/i/grok
                [DEBUG] Successfully opened: https://x.com/i/grok
                [WARNING] OBS Studio not found in system PATH.
                [WARNING] LM Studio not found in system PATH.
                [WARNING] AnythingLLM not found in system PATH.
                [WARNING] Obsidian not found in system PATH.
                [WARNING] OBS Studio not found in system PATH.
                [WARNING] LM Studio not found in system PATH.
                [WARNING] AnythingLLM not found in system PATH.
                [WARNING] Obsidian not found in system PATH.
                [WARNING] Stream Deck not found in system PATH.
                [WARNING] AnythingLLM not found in system PATH.
                [WARNING] Obsidian not found in system PATH.
                [WARNING] Stream Deck not found in system PATH.
                [WARNING] Obsidian not found in system PATH.
                [WARNING] Stream Deck not found in system PATH.
                [WARNING] Visual Studio Code not found in system PATH.
                [WARNING] Stream Deck not found in system PATH.
                [WARNING] Visual Studio Code not found in system PATH.
                [WARNING] Visual Studio Code not found in system PATH.
                [WARNING] Docker Desktop not found in system PATH.
                [DEBUG] Updating Chocolatey packages
                [DEBUG] Chocolatey package update initiated
                [DEBUG] Opening Windows Update settings
                [DEBUG] Chocolatey package update initiated
                [DEBUG] Opening Windows Update settings
                [DEBUG] Windows Update settings opened
                [DEBUG] Opening Windows Update settings
                [DEBUG] Windows Update settings opened
                [DEBUG] Script completed on 02/28/2025 09:47:53
                [DEBUG] Windows Update settings opened
                [DEBUG] Script completed on 02/28/2025 09:47:53
                [DEBUG] Script completed on 02/28/2025 09:47:53
                
                =======================================
                ✅ All startup applications launched!
                =======================================
                Press Enter to close this terminal window or type 'stay' to keep it open:
                
                

Imported from rifaterdemsahin.com · 2025