Functions/NIOS/Private/Set-NIOSContext.ps1
function Set-NIOSContext { param( [Parameter(Mandatory=$true)] [String]$Name, [Parameter(Mandatory=$true)] [System.Object]$Config, [Switch]$NoSwitchProfile ) $Configs = Get-NIOSContext -Raw if ($Configs.Contexts."$($Name)") { Write-Warning "Are you sure you want to overwrite the connection profile: $($Name)?" -WarningAction Inquire Write-Host "Overwriting saved connection profile: $($Name).." -ForegroundColor Green $Configs.Contexts."$($Name)" = $Config } else { Write-Host "Creating new connection profile: $($Name).." -ForegroundColor Green $Configs.Contexts | Add-Member -MemberType NoteProperty -Name $($Name) -Value $($Config) } if (-not $NoSwitchProfile) { Write-Host "Active connection profile set to: $($Name)" -ForegroundColor Cyan $Configs.CurrentContext = $($Name) } $Configs | ConvertTo-Json -Depth 5 | Out-File $Script:NIOSConfigFile -Force } |