UI/_OnOptionsSourceInitialized.ps1
function _OnOptionsSourceInitialized { $Options_ModuleVersionLabel.Content = "Module Version: $($Module.Version)" $SettingsSaved = $false #region Entra ID $Options_EntraIDCheckBox.IsChecked = $STTSettings.FeatureSettings.Entra $Options_EntraTenantTextBox.Text = $STTSettings.EntraSettings.TenantURL $Options_EntraConnectServerTextBox = $STTSettings.EntraSettings.EntraConnectServer if ($Options_EntraIDCheckBox.IsChecked) { # TODO add the two textblocks $Options_EntraTenantTextBox.Visibility = "Visible" # TODO this line is broken $Options_EntraConnectServerTextBox.Visibility = "Visible" } else { # TODO add the two textblocks $Options_EntraTenantTextBox.Visibility = "Collapsed" # TODO this line is broken $Options_EntraConnectServerTextBox.Visibility = "Collapsed" } #endregion #region Modules $ModulesToSearch = @('MSOnline', 'ExchangeOnlineManagement') $RequiredModules = Get-InstalledModule -Name $ModulesToSearch -ErrorAction SilentlyContinue $Object = @() if ($RequiredModules) { $Object += [PSCustomObject]$RequiredModules | Select-Object Name, Version, Repository, Description } else { $Object += [PSCustomObject]@{ Error = 'Error getting modules. Verify they are installed.' } } $Options_InstalledModulesDataGrid.ItemsSource = $Object #endregion #region DC Settings $DCs = Get-ADDomainController @GetObjectSplat -Filter * foreach ($DC in $DCs) { $Options_DCComboBox.Items.Add($DC.HostName) } $Options_DCComboBox.Text = $STTSettings.DCSettings.DomainController $Options_CredentialsAlternateCheckBox.IsChecked = $STTSettings.DCSettings.UseAlternateCredentials if ($StoredCredential) { $Options_CredentialsUsernameTextBox.Text = $StoredCredential.Username $Options_CredentialsPasswordPasswordBox.Password = "You can't read this." } #endregion #region SCCM $Options_SCCMIntegrationCheckBox.IsChecked = $STTSettings.FeatureSettings.SCCM $Options_SCCMServerTextBox.Text = $STTSettings.SCCMSettings.SCCMServerHostname if ($Options_SCCMIntegrationCheckBox.IsChecked) { $Options_SCCMServerTextBox.IsEnabled = $true $Options_SCCMCollectionComboBox.IsEnabled = $true try { $SCCMCollections = _GetSCCMInformationQuerySTT -Route wmi -Connector 'SMS_Collection' | Sort-Object } catch { $Options_SavingTextBlock.Text = 'Unable to get collections from SCCM. Verify that you have permissions to read SCCM.' } if ($SCCMCollections) { foreach ($Collection in $($SCCMCollections | Sort-Object Name)) { $Options_SCCMCollectionComboBox.Items.Add($Collection.Name) } $Options_SCCMCollectionComboBox.SelectedItem = $STTSettings.SCCMSettings.SCCMDefaultCollection } else { $Options_SCCMCollectionComboBox.Text = 'Unable to load.' } } else { $Options_SCCMServerTextBox.IsEnabled = $false $Options_SCCMCollectionComboBox.IsEnabled = $false } #endregion #region Exchange on-premise $Options_ExchangeIntegrationCheckBox.IsChecked = $STTSettings.FeatureSettings.Exchange #endregion switch ($STTSettings.Theme) { 'Dark' { $Options_DarkThemeRadioButton.IsChecked = $true } 'Light' { $Options_LightThemeRadioButton.IsChecked = $true } 'Violet' { $Options_VioletThemeRadioButton.IsChecked = $true } Default { } } #region Stored Objects $Options_ObjectCacheTextBox.Text = $STTSettings.ObjectsSettings.ObjectStorageFolder #endregion } |