Private/Options/_WUGValidationAndSave.ps1
function _WUGValidationAndSave { if ($Options_WUGIntegrationCheckBox.IsChecked) { if ($STTSettings.FeatureSettings.WhatsUpGold -eq $false) { if ($Options_WUGCredentialsUsernameTextBox.Text) { $Username = $Options_WUGCredentialsUsernameTextBox.Text } else { $MessageSplat = @{ MessageText = 'Please provide a username.' MessageIcon = 'Hand' ButtonType = 'OK' MessageTitle = 'WhatsUpGold Validation Error' } _ShowMessageBox @MessageSplat } if ($Options_WUGCredentialsPasswordPasswordBox) { $Password = $Options_WUGCredentialsPasswordPasswordBox.SecurePassword } else { $MessageSplat = @{ MessageText = 'Please provide a password.' MessageIcon = 'Hand' ButtonType = 'OK' MessageTitle = 'WhatsUpGold Validation Error' } _ShowMessageBox @MessageSplat } $Credential = New-Object System.Management.Automation.PSCredential ("$Username", $Password) $Credential | Export-Clixml -Path $env:APPDATA\LoganShell\WUG.xml } } } |