Add-Type -AssemblyName System.Windows.Forms # Define the path to the DefaultServer.txt file $DefaultServerFile = ".\DefaultServer.txt" # Check if the file exists and read the server address if (Test-Path -Path $DefaultServerFile) { $CurrentServer = Get-Content -Path $DefaultServerFile | ForEach-Object { $_.Trim() } } else { # Fallback to a default server address if the file is missing $CurrentServer = "exchange2019.windows.local" } # Credential Storage function Get-ExchangeCredentialsFromXml { if (Test-Path .\AdminCredential.xml) { try { $credential = Import-Clixml -Path .\AdminCredential.xml return $credential } catch { [System.Windows.Forms.MessageBox]::Show("Error reading credentials from AdminCredential.xml: $($_.Exception.Message)", "Error", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Error) return $null } } else { [System.Windows.Forms.MessageBox]::Show("AdminCredential.xml not found.", "Error", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Error) return $null } } # Create the main form (window) $form = New-Object System.Windows.Forms.Form $form.Text = "Exchange Server Management Toolbox" $form.Width = 400 $form.Height = 450 $form.StartPosition = "CenterScreen" # Add the logo (PictureBox) $logo = New-Object System.Windows.Forms.PictureBox $logo.Image = [System.Drawing.Image]::FromFile((Join-Path -Path (Get-Location).Path -ChildPath "Pictures\exchange.png")) # Use relative path if image is in the same folder $logo.Width = 350 # Set larger width $logo.Height = 100 # Set larger height $logo.Top = 10 $logo.Left = 20 $logo.SizeMode = "StretchImage" # Create the OWA button $buttonOWA = New-Object System.Windows.Forms.Button $buttonOWA.Text = "Open OWA" $buttonOWA.Width = 120 $buttonOWA.Height = 40 $buttonOWA.Top = 150 $buttonOWA.Left = 50 $buttonOWA.BackColor = "LightBlue" $buttonOWA.Add_Click({ Start-Process "https://$CurrentServer/owa/" }) # Create the O365 button $buttonO365 = New-Object System.Windows.Forms.Button $buttonO365.Text = "Open O365" $buttonO365.Width = 120 $buttonO365.Height = 40 $buttonO365.Top = 200 $buttonO365.Left = 50 $buttonO365.BackColor = "LightBlue" $buttonO365.Add_Click({ Start-Process "http://outlook.office365.com/" }) # Create the Azure button $buttonAzure = New-Object System.Windows.Forms.Button $buttonAzure.Text = "Open Azure" $buttonAzure.Width = 120 $buttonAzure.Height = 40 $buttonAzure.Top = 250 $buttonAzure.Left = 200 $buttonAzure.BackColor = "Yellow" $buttonAzure.Add_Click({ Start-Process "Firefox.exe" "https://portal.azure.com/#home" }) # Create the AD button $buttonAD = New-Object System.Windows.Forms.Button $buttonAD.Text = "Open Active Directory" $buttonAD.Width = 120 $buttonAD.Height = 40 $buttonAD.Top = 300 $buttonAD.Left = 50 $buttonAD.BackColor = "Orange" $buttonAD = New-Object System.Windows.Forms.Button $buttonAD.Text = "Open Active Directory" $buttonAD.Width = 120 $buttonAD.Height = 40 $buttonAD.Top = 300 $buttonAD.Left = 50 $buttonAD.BackColor = "Orange" $buttonAD.Add_Click({ # Prompt for credentials $cred = Import-Clixml -Path ".\AdminCredential.xml" Write-Host "Executing Active Directory as the user: $($cred.UserName)" # Run Active Directory Users and Computers as the domain admin Start-Process C:\Windows\System32\mmc.exe -ArgumentList C:\Windows\System32\dsa.msc -Credential $cred }) # Create the EAC button $buttonEAC = New-Object System.Windows.Forms.Button $buttonEAC.Text = "Open EAC" $buttonEAC.Width = 120 $buttonEAC.Height = 40 $buttonEAC.Top = 150 $buttonEAC.Left = 200 $buttonEAC.BackColor = "LightGreen" $buttonEAC.Add_Click({ Start-Process "https://$CurrentServer/ecp/" }) # Create the O365 Admin button $button0365Admin = New-Object System.Windows.Forms.Button $button0365Admin.Text = "Open O365 Admin" $button0365Admin.Width = 120 $button0365Admin.Height = 40 $button0365Admin.Top = 200 $button0365Admin.Left = 200 $button0365Admin.BackColor = "LightGreen" $button0365Admin.Add_Click({ Start-Process "Firefox.exe" "https://admin.microsoft.com/AdminPortal/Home" }) # Create the Addins button $buttonAddins = New-Object System.Windows.Forms.Button $buttonAddins.Text = "Open Addins" $buttonAddins.Width = 120 $buttonAddins.Height = 40 $buttonAddins.Top = 250 $buttonAddins.Left = 50 $buttonAddins.BackColor = "Yellow" $buttonAddins.Add_Click({ Start-Process "https://appsource.microsoft.com/en-us/marketplace/apps?product=office%3Boutlook&page=1&src=office&corrid=745da53e-51b8-4454-1504-5865bc16ea5e&omexanonuid=&referralurl=&ClientSessionId=29f52f70-499b-4b47-b747-b3c7809042ec" }) # Create the Powershell button $buttonPowershell = New-Object System.Windows.Forms.Button $buttonPowershell.Text = "Open Powershell" $buttonPowershell.Width = 120 $buttonPowershell.Height = 40 $buttonPowershell.Top = 300 $buttonPowershell.Left = 200 $buttonPowershell.BackColor = "Orange" $buttonPowershell.Add_Click({ try { # Start the process with elevated privileges $cred = Import-Clixml -Path "AdminCredential.xml" Write-Host "Executing PowerShell (ISE) as the user: $($cred.UserName)" Start-Process -FilePath "PowerShell_ISE.exe" -Credential $cred } catch { Write-Host -ForegroundColor Red "Failed to start the process: $_" } }) # Create the Notes button in the Main Menu $buttonNotes = New-Object System.Windows.Forms.Button $buttonNotes.Text = "Notes" $buttonNotes.Width = 120 $buttonNotes.Height = 40 $buttonNotes.Top = 350 $buttonNotes.Left = 50 $buttonNotes.BackColor = "Cyan" # Notes Menu Template $buttonNotes.Add_Click({ $reportingForm = New-Object System.Windows.Forms.Form $reportingForm.Text = "Notes" $reportingForm.Size = New-Object System.Drawing.Size(950, 600) $reportingForm.StartPosition = "CenterScreen" $reportTextBox = New-Object System.Windows.Forms.RichTextBox $reportTextBox.Location = New-Object System.Drawing.Point(300, 20) $reportTextBox.Size = New-Object System.Drawing.Size(620, 500) $reportTextBox.Multiline = $true $reportTextBox.ScrollBars = "Vertical" # Notes Menu Read Me Button $databaseSizeButton = New-Object System.Windows.Forms.Button $databaseSizeButton.Location = New-Object System.Drawing.Point(20, 20) $databaseSizeButton.Size = New-Object System.Drawing.Size(250, 30) $databaseSizeButton.Text = "Read Me" # Notes Menu About Button $databaseMailboxListButton = New-Object System.Windows.Forms.Button $databaseMailboxListButton.Location = New-Object System.Drawing.Point(20, 60) $databaseMailboxListButton.Size = New-Object System.Drawing.Size(250, 30) $databaseMailboxListButton.Text = "About" # Notes Menu AutoReply Templates Button $databaseMailboxSizeButton = New-Object System.Windows.Forms.Button $databaseMailboxSizeButton.Location = New-Object System.Drawing.Point(20, 100) $databaseMailboxSizeButton.Size = New-Object System.Drawing.Point(250, 30) $databaseMailboxSizeButton.Text = "AutoReply Templates" # Notes Menu End of Life Button $inactiveMailboxButton = New-Object System.Windows.Forms.Button $inactiveMailboxButton.Location = New-Object System.Drawing.Point(20, 140) $inactiveMailboxButton.Size = New-Object System.Drawing.Size(250, 30) $inactiveMailboxButton.Text = "End Of Life Info" # Notes Menu Major Outage Button $sharedMailboxesListButton = New-Object System.Windows.Forms.Button $sharedMailboxesListButton.Location = New-Object System.Drawing.Point(20, 180) $sharedMailboxesListButton.Size = New-Object System.Drawing.Size(250, 30) $sharedMailboxesListButton.Text = "Major Outages" # Notes Menu Microsoft Articles Button $forwardingRulesListButton = New-Object System.Windows.Forms.Button $forwardingRulesListButton.Location = New-Object System.Drawing.Point(20, 220) $forwardingRulesListButton.Size = New-Object System.Drawing.Size(250, 30) $forwardingRulesListButton.Text = "Microsoft Articles" # Notes Menu Microsoft Licensing Button $userSentItemsButton = New-Object System.Windows.Forms.Button $userSentItemsButton.Location = New-Object System.Drawing.Point(20, 260) $userSentItemsButton.Size = New-Object System.Drawing.Size(250, 30) $userSentItemsButton.Text = "Microsoft Licensing" $sharedSentItemsButton = New-Object System.Windows.Forms.Button $sharedSentItemsButton.Location = New-Object System.Drawing.Point(20, 300) $sharedSentItemsButton.Size = New-Object System.Drawing.Size(250, 30) $sharedSentItemsButton.Text = "Ping Exchange Check" # Add all buttons to the form $reportingForm.Controls.Add($databaseSizeButton) $reportingForm.Controls.Add($databaseMailboxListButton) $reportingForm.Controls.Add($databaseMailboxSizeButton) $reportingForm.Controls.Add($inactiveMailboxButton) $reportingForm.Controls.Add($sharedMailboxesListButton) $reportingForm.Controls.Add($forwardingRulesListButton) $reportingForm.Controls.Add($userSentItemsButton) $reportingForm.Controls.Add($sharedSentItemsButton) $reportingForm.Controls.Add($reportTextBox) $databaseSizeButton.Add_Click({ try { $sampleText = @" {\rtf1\ansi\deff0 {\colortbl ;\red255\green0\blue0;\red0\green255\blue0;} \cf1\b Welcome to the Exchange Server Management Tool!\b0\line\line \cf0 This tool has been designed to help manage On-Prem Exchange Users.\line This tool has been designed for Microsoft Exchange 2019 only.\line\line \b Here are some quick instructions for running this application:\b0\line - Users Domain Accounts should be a Local Administrator on their own workstation.\line - Users will need to right click and select "Run as Administrator" and select yes\line - Users will then log on with an account that has Domain Admin rights.\line\line \b Here are some quick tips for using this application:\b0\line - Click 'Open OWA' to access the Exchanges Outlook Web Access Page.\line - Click 'Open EAC' to manage Exchange settings via the Exchange Admin Center.\line - Click 'Open O365' to access the Office365 Web Access Page.\line - Click 'Open O365 Admin' to access the Office365 Admin Center.\line - Click 'Open Azure' to access the Azure Management Page.\line - Click 'Open Addins' to search for web-based Addins for Microsoft Office.\line - Click 'Open Active Directory' to open Active Directory using the account you logged in with.\line - Click 'Open Powershell' to open Powershell ISE using the account you logged in with.\line - Click 'Notes' to view information\line\line \b Here are some quick instructions for modifying this application:\b0\line - The Executable can be unpacked to see the full scripts using a bat to exe converter.\line - All the poweshell scripts are individually saved for easy cusomization.\line - Reports are saved to the Downloads Folder.\line\line \b Thank you for choosing this tool to simplify your IT workflows!\b0 } "@ $reportTextBox.Rtf = $sampleText } catch { $reportTextBox.Text = "Error: $($_.Exception.Message)" } }) $databaseMailboxListButton.Add_Click({ try { $sampleText = @" {\rtf1\ansi\deff0 {\colortbl ;\red255\green0\blue0;\red0\green0\blue255;} \cf1\b Welcome to the Exchange Server Management Tool!\b0\line\line \cf0 Created by: Shane Small\line Last Update: 11/04/2025\line\line \b Version 1.0.0\b0\line Version 1.0.0 released to start using version control\line\line \b Version 1.9 (Beta)\b0\line Created Directory Structure for this project.\line Full Rebuild of menus to consolidate options\line Integrated Version Control via version.txt file\line Integrated Automatic Update Mechanism\line\line \b Version 1.8 (Beta)\b0\line Added functionality to Auth to Azure\line Added option to check if Azure user is Disabled\line Added functionality to Auth to O365\line Added New Report - Office365 Mailbox Report\line Added New Report - User Report by Organizational Unit\line Added Email Signature Management for OWA (On-Prem)\line Added Domain Connectivity Status to the main menu\line Added Cisco VPN Status to the main menu.\line\line \b Version 1.7 (Beta)\b0\line Added Domain Authentication to saving credentials to start of script to confirm correct password is used.\line Active Directory & Powershell will now open using the saved credentials.\line\line \b Version 1.6 (Beta)\b0\line Added Welcome Message\line Added Section - Settings\line Added Section - Settings - Added function for user to change the default username\line Added Section - Settings - Added function for user to change the default exchange server\line Updated Scripts to Accomodate the dynamic exchange server change.\line Updated Main Menu to show overview of current settings.\line\line \b Version 1.5 (Beta)\b0\line Added function - Added Toolbox option to the Main Menu\line Added function - Updates to Toolbox\line Added function - Generate HTML Reports\line\line \b Version 1.4 (Beta)\b0\line Added Section - User Management\line Added Section - User Reports Section\line Windows Form Toolbox Created\line\line \b Version 1.3 (Beta)\b0\line Update of Various Scripts\line Added function to Hide or Unhide User from Exchange Lists\line Added function to Update Offline Addressbook\line Added function to set the Autoreply Enddate\line\line \b Thank you for choosing this tool to simplify your IT workflows!\b0 "@ $reportTextBox.Rtf = $sampleText } catch { $reportTextBox.Text = "Error: $($_.Exception.Message)" } }) $databaseMailboxSizeButton.Add_Click({ try { $sampleText = @" {\rtf1\ansi\deff0 {\colortbl ;\red255\green0\blue0;\red0\green0\blue255;} \cf1\b AutoReply Templates Explained \b0\line\line \cf0\b AutoReply Template 1 \b0\line\line \cf0 Thank you for your email. \line Please be informed that is no longer working at . \line This mailbox is currently unattended. Information Classification:Restricted. \line\line \cf0\b AutoReply Template 2 \b0\line\line \cf0 Thank you for your email. \line Please be informed that is no longer working at . \line Please RE-SEND your enquiry to for further assistance. \line This mailbox is currently unattended. Information Classification:Restricted. \line\line \b Thank you for choosing this tool to simplify your IT workflows! \b0\line\ "@ $reportTextBox.Rtf = $sampleText } catch { $reportTextBox.Text = "Error: $($_.Exception.Message)" } }) $inactiveMailboxButton.Add_Click({ try { $sampleText = @" {\rtf1\ansi\deff0 {\colortbl ;\red255\green0\blue0;\red0\green0\blue255;} \cf1\b End Of Life Information \b0\line\line \cf0\b End of support for Exchange Server 2016 \b0\line \cf0 Microsoft's Support for Exchange 2016 will end on October 14, 2025. \line\line \cf0\b End of support for Exchange Server 2019 \b0\line \cf0 Microsoft's Support for Exchange 2019 will end on October 14, 2025. \line\line \cf0\b End of support for Office 2019 \b0\line \cf0 Microsoft's Support for Office 2019 will end on October 14, 2025. \line\line \cf0\b End of support for Windows 10 \b0\line \cf0 Microsoft's support for Windows 10 will end on October 14, 2025. \line\line \cf0\b End of life for Classic Microsoft Teams \b0\line \cf0 The end of availability for the classic Teams client starts July 1, 2025. \line\line \cf0\b End of life for Skype \b0\line \cf0 Microsoft will retire consumer Skype on May 5, 2025. \line\line \cf0 \b End of support for COM and VSTO add-inn support in the new Outlook \b0\line \cf0 COM and VSTO add-ins aren't supported in the new Outlook on Windows. \line Web Based add-ins are available on https://appsource.microsoft.com/ for the new Outlook. \line However, COM and VSTO add-ins are still supported in the classic Outlook on Windows desktop client. \line\line \b Thank you for choosing this tool to simplify your IT workflows! \b0\line "@ $reportTextBox.Rtf = $sampleText } catch { $reportTextBox.Text = "Error: $($_.Exception.Message)" } }) $sharedMailboxesListButton.Add_Click({ try { $sampleText = @" {\rtf1\ansi\deff0 {\colortbl ;\red255\green0\blue0;\red0\green0\blue255;} \cf1\b Major Outage Information \b0\line\Line \cf0\b Microsoft 365 (Consumer) Status Page \b0\ \cf0 Provides details on service status for consumer Microsoft 365 users. \Line \cf0 https://portal.office.com/servicestatus \Line\Line \cf0\b Microsoft 365 Admin Center Status Page \b0\ \cf0 Offers service status specifically for Microsoft 365 Admin Center users. \Line \cf0 https://status.cloud.microsoft/ \Line\Line \cf0\b Microsoft 365 Service Health \b0\ \cf0 View the current health of your Microsoft 365 services. (Requires login) \Line \cf0 https://portal.office.com/adminportal/home#/servicehealth \Line\Line \cf0\b Microsoft 365 Network Health Status Map \b0\ \cf0 Check connectivity issues geographically. \Line \cf0 https://connectivity.office.com/status \Line\Line \cf0\b Azure Service Status Page \b0\ \cf0 Status updates for Azure services. \Line \cf0 https://portal.azure.com/#view/Microsoft_Azure_Health/AzureHealthBrowseBlade/~/serviceIssues \Line\Line \b Thank you for choosing this tool to simplify your IT workflows! \Line "@ $reportTextBox.Rtf = $sampleText } catch { $reportTextBox.Text = "Error: $($_.Exception.Message)" } }) $forwardingRulesListButton.Add_Click({ try { $sampleText = @" {\rtf1\ansi\deff0 {\colortbl ;\red255\green0\blue0;\red0\green0\blue255;} \cf1\b Microsoft Articles \b0\line\Line \cf0\b Exchange Online \b0 https://learn.microsoft.com/en-us/exchange/troubleshoot/exchange-online-welcome \Line\Line \cf0\b Exchange Server \b0 https://learn.microsoft.com/en-us/exchange/troubleshoot/exchange-server-welcome \Line\Line \cf0\b Exchange Hybrid \b0 https://learn.microsoft.com/en-us/exchange/troubleshoot/exchange-hybrid-welcome \Line\Line \cf0\b Outlook Client \b0 https://learn.microsoft.com/en-us/outlook/troubleshoot/outlook-client-welcome \Line\Line \cf1\b Bookmarked Articles \b0\line\line \cf0\b Messages sent from a shared mailbox aren't saved to the Sent Items folder of the shared mailbox in Outlook \b0 https://learn.microsoft.com/en-us/exchange/troubleshoot/user-and-shared-mailboxes/sent-mail-is-not-saved \line\line \cf0\b Problem \b0\line \cf0 Assume that you're using Microsoft Outlook 2010 or a later version, and you've been delegated permission to send email messages as another user or on behalf of another user from a shared mailbox. However, when you send a message as another user or on behalf of the user, the sent message isn't saved to the Sent Items folder of the shared mailbox. Instead, it's saved to the Sent Items folder of your mailbox. \line\line \cf0\b Cause \b0\line \cf0 In Microsoft 365, shared mailboxes don't require a license and can't be added to Outlook as an independent mailbox. You can't sign in to a shared mailbox. Instead, you sign in to your own mailbox, and then you open the shared mailbox. When you send or reply to a new message from the shared mailbox, Outlook automatically sends or replies from the sender's account. Therefore, messages are stored in the Sent Items folder of the sender's mailbox. \line\line \cf0\b Solution \b0\line \cf0 Configure the mailbox to save a copy of the message to the Sent Items folder of the shared mailbox in Exchange Online or in on-premises Exchange Server. The "Check All Shared mailboxes for Sent Items delivery settings Report" Report wil fix this issue. \line\line \b Thank you for choosing this tool to simplify your IT workflows! \b0\line "@ $reportTextBox.Rtf = $sampleText } catch { $reportTextBox.Text = "Error: $($_.Exception.Message)" } }) $sharedSentItemsButton.Add_Click({ try { # Clear the TextBox content before starting the process $reportTextBox.Clear() # Reset any existing formatting and set default color (black) $reportTextBox.SelectAll() $reportTextBox.SelectionColor = [System.Drawing.Color]::Black $reportTextBox.DeselectAll() # Display an initial message in the TextBox $reportTextBox.AppendText("Testing Connectivity to Exchange Server...`r`n") # Force the GUI to refresh and show updated content [System.Windows.Forms.Application]::DoEvents() # Initialize variables for success count and total pings $successfulPings = 0 $totalPings = 5 # Perform five consecutive pings with a one-second delay between each for ($i = 1; $i -le $totalPings; $i++) { $pingResult = Test-Connection -ComputerName "$CurrentServer" -Count 1 -ErrorAction Stop # Append the result of the current ping directly to the TextBox $reportTextBox.AppendText("Ping $i successful! Response time: $($pingResult.ResponseTime) ms`r`n") $successfulPings++ # Force the GUI to refresh and show updated content [System.Windows.Forms.Application]::DoEvents() # Introduce a delay of one second between pings Start-Sleep -Seconds 1 } # Append a summary at the end if ($successfulPings -eq $totalPings) { $reportTextBox.AppendText("`r`nSummary: The connection to the server is stable.") } else { $reportTextBox.AppendText("`r`nSummary: The connection to the server is unstable.") } } catch { # Display error message in the TextBox if pings fail $reportTextBox.Clear() # Clear previous content if an error occurs $reportTextBox.AppendText("Testing Connectivity to Exchange Server...`r`nPing failed: $($_.Exception.Message)`r`nSummary: The connection to the server is unavailable.") } }) # Button Click Event for "Microsoft Licensing" $userSentItemsButton.Add_Click({ $reportingForm = New-Object System.Windows.Forms.Form $reportingForm.Text = "Notes with Image" $reportingForm.Size = New-Object System.Drawing.Size(950, 600) $reportingForm.StartPosition = "CenterScreen" # Create a SplitContainer to divide the form $splitContainer = New-Object System.Windows.Forms.SplitContainer $splitContainer.Dock = "Fill" $splitContainer.Orientation = [System.Windows.Forms.Orientation]::Horizontal # Add RichTextBox to the left pane $reportTextBox = New-Object System.Windows.Forms.RichTextBox $reportTextBox.Dock = "Fill" $reportTextBox.Multiline = $true $reportTextBox.ScrollBars = "Vertical" $reportTextBox.Rtf = @" {\rtf1\ansi\deff0 {\colortbl ;\red255\green0\blue0;\red0\green0\blue255;} \cf1\b Microsoft Office365 Licensing \b0\line\line \cf0\b A1 License: \b0\line\line \cf0 Free for educational institutions. \line Includes web-based Office apps (Word, Excel, PowerPoint, etc.). \line Provides collaboration tools like Teams, SharePoint Online, and OneDrive for Business. \line Does not include desktop versions of Office applications. \line\line \cf0\b A3 License: \b0 \line\line \cf0 Paid subscription with additional features. \line Includes desktop versions of Office apps for installation on devices. \line Offers advanced security features like Azure Information Protection. \line Includes Exchange Online Plan 2 for enhanced email capabilities. \line\line \cf0\b A5 License: \b0 \line\line \cf0 Premium subscription with the most comprehensive features. \line Includes advanced analytics tools like Power BI Pro. \line Provides enhanced security and compliance features, including Phone System and Audio Conferencing. \line Ideal for institutions needing enterprise-level capabilities. \line\line \b Thank you for choosing this tool to simplify your IT workflows! \b0\line "@ $splitContainer.Panel1.Controls.Add($reportTextBox) # Add PictureBox to the right pane $pictureBox = New-Object System.Windows.Forms.PictureBox $pictureBox.Dock = "Fill" $pictureBox.SizeMode = "StretchImage" # Load the image file $imagePath = (Join-Path -Path (Get-Location).Path -ChildPath "Pictures\office365licences.png") if (Test-Path $imagePath) { $pictureBox.Image = [System.Drawing.Image]::FromFile($imagePath) } else { $reportTextBox.Text += "`n[Error: Image file not found!]" } $splitContainer.Panel2.Controls.Add($pictureBox) # Add SplitContainer to the form $reportingForm.Controls.Add($splitContainer) # Set SplitterDistance AFTER adding the SplitContainer to the form $splitContainer.SplitterDistance = 100 # Adjust the width of the text side # Display the form $reportingForm.Add_Shown({$reportingForm.Activate()}) [void]$reportingForm.ShowDialog() }) $reportingForm.Add_Shown({$reportingForm.Activate()}) [void]$reportingForm.ShowDialog() }) # Add an Exit button for closing the application $buttonExit = New-Object System.Windows.Forms.Button $buttonExit.Text = "Exit" $buttonExit.Width = 120 $buttonExit.Height = 40 $buttonExit.Top = 350 $buttonExit.Left = 200 $buttonExit.BackColor = "LightCoral" $buttonExit.Add_Click({ Remove-PSSession -Session $global:exchangeSession $form.Close() }) # Add all controls to the form $form.Controls.Add($logo) $form.Controls.Add($buttonOWA) $form.Controls.Add($buttonO365) $form.Controls.Add($buttonAzure) $form.Controls.Add($buttonAD) $form.Controls.Add($buttonEAC) $form.Controls.Add($button0365Admin) $form.Controls.Add($buttonPowershell) $form.Controls.Add($buttonAddins) $form.Controls.Add($buttonNotes) $form.Controls.Add($buttonExit) # Show the form $form.Add_Shown({$form.Activate()}) $form.ShowDialog()