Functions/Ses/Sesio-Config.ps1
function Sesio-Config { param ( [Parameter(Position=0, Mandatory=$true)] [string]$Command, [Parameter(ValueFromRemainingArguments=$true)] $RemainingArgs ) switch ($Command.ToLower()) { "add" { $params = @{} for ($i = 0; $i -lt $RemainingArgs.Count; $i += 2) { if ($i + 1 -lt $RemainingArgs.Count) { $params[$RemainingArgs[$i].TrimStart('-')] = $RemainingArgs[$i + 1] } } Config-Add @params } "azure" { Config-Azure @RemainingArgs } "list" { Config-List @RemainingArgs } "help" { Config-Help } default { Write-Host "Unknown command: $Command" } } } function Config-Azure { # Check if azd is installed $azdInstalled = $null -ne (Get-Command azd -ErrorAction SilentlyContinue) if (-not $azdInstalled) { $downloadChoice = Read-Host "Azure Developer CLI (azd) is not installed. Do you want to download and install it? (Y/N)" if ($downloadChoice -eq 'Y' -or $downloadChoice -eq 'y') { Write-Host "Downloading and installing Azure Developer CLI (azd)..." winget install Microsoft.AzureDeveloperCLI # Refresh the PATH to include the newly installed azd $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") Write-Host "Azure Developer CLI (azd) has been installed." } else { Write-Host "Azure Developer CLI (azd) is required for this operation. Exiting." return } } # Verify azd installation try { $azdVersion = azd version Write-Host "Azure Developer CLI (azd) version: $azdVersion" } catch { Write-Host "Error: Unable to verify Azure Developer CLI (azd) installation. Please install it manually and try again." return } # Login to Azure Write-Host "Logging in to Azure..." azd auth login # List available subscriptions Write-Host "Available Azure subscriptions:" azd account list # Prompt user to select a subscription $subscriptionId = Read-Host "Enter the Subscription ID you want to use" # Set the selected subscription azd account set --subscription $subscriptionId Write-Host "Azure configuration completed successfully." } function Config-Add { Write-Host "Adding config" } function Config-List { Write-Host "Listing config" } function Config-Help { Write-Host "Help" } export-modulemember -function Sesio-Config |