pcdiag.ps1


<#PSScriptInfo
 
.VERSION 1.1
 
.GUID 3954da33-0938-4f4e-9249-ebb7dfad3f98
 
.AUTHOR jserlick@gmail.com
 
.COMPANYNAME
 
.COPYRIGHT 8/8/2017
 
.TAGS PCDiag
 
.LICENSEURI
 
.PROJECTURI
 
.ICONURI
 
.EXTERNALMODULEDEPENDENCIES ActiveDirectory, Msolonline
 
.REQUIREDSCRIPTS
 
.EXTERNALSCRIPTDEPENDENCIES
 
.RELEASENOTES
    INFO : If script does not run you will need to change the computer's execution policy
                      to do this start an elevated instance of powershell, run as "Administrator"
                  and run "set-executionpolicy remotesigned"
    Prerequisite : PowerShell V 3.0 or Higher *Most functions work with PowerShell V 2.0
    Working Directory : C:\PCDiag
    External Script Sources : Self Elevating script - https://blogs.msdn.microsoft.com/virtual_pc_guy/2010/09/23/a-self-elevating-powershell-script
                :Submenu script - https://stealthfield.wordpress.com/2013/08/07/powershell-menu-template-ps1-file/
                : O365 Report script - https://gallery.technet.microsoft.com/office/Get-Office-365-Report-17417c2a
 
    REVISION HISTORY :
    Version Date Description of changes
        -----------------------------------------------------------------------------------------------------------------
        1.0 12/7/2016 - Established baseline of Version 1.0
 
    1.0 12/19/2016 - O365 Exchange Operations - added O365 Report & Disable Clutter Function
     
    1.0 12/21/2016 - Added w32tm query to all automatic data collection operations
 
    1.1 02/12/2017 - Modified script to create timestamped directories in the working directory
                02/15/2017 - Updated scripts with output targets to create files in timestamped directory
                02/16/2017 - Added version indicators in script segments comments
                02/16/2017 - Added Main Menu Option 7 - Local Exchange Operations
                02/21/2017 - Combined Automatic Data Collection scripts into a sub menu
                03/29/2017 - Added yellow color to Quit options for menus
                03/29/2017 - Added 2 new Main menu options, option 9 & 0
                04/07/2017 - Added script to connect to Local Exchange servers
                04/19/2017 - Renamed Main Menu Option 6 to "Network Operations", moved menu options to menu Manual Operations
                04/19/2017 - Added Main Menu Option 8 "Powershell Gallery"
                04/19/2017 - Added new function List all GPO settings in Main Menu Option 3 Active Directory & Domain Operations
                04/19/2017 - Added new function Reset Network Adapter in Main Menu Option 1 Manual Operations
                04/20/2017 - Added new Working Directory PSG to be used for powershell gallery repository
                07/13/2017 - Added new function List Certicate Authority in Main Menu Option 3 Active Directory & Domain Operation
        08/08/2017 - Updated Scriptfileinfo to meet Powershell Gallery requirements
        08/08/2017 - Uploaded script to The Powershell Gallery
        08/08/2017 - Working on Version 2.0, complete rework with windows GUI
 
 
#>


<#
 
.DESCRIPTION
PCDiag is a menu based tool that contains manual diagnostic commands, O365 management scripts, Active Directory scripts, Remote Management scripts & mutliple automatic data collection scripts for Windows based Workstations & Servers
 
#>
 
Param()

<#PSScriptInfo
 
.VERSION 1.1
 
.GUID 3954da33-0938-4f4e-9249-ebb7dfad3f98
 
.AUTHOR
    Author : Justin Serlick
    Email : jserlick@gmail.com
 
.COMPANYNAME
    None
 
.COPYRIGHT
    2017
 
.TAGS
    PCDIAG
 
.LICENSEURI
    None
 
.PROJECTURI
    None
 
.ICONURI
    None
 
.EXTERNALMODULEDEPENDENCIES
    ActiveDirectory
    Msolonline
 
.REQUIREDSCRIPTS
    None
 
.EXTERNALSCRIPTDEPENDENCIES
 
 
<# Self Elevating script v1.1 #>

# Get the ID and security principal of the current user account
$myWindowsID = [System.Security.Principal.WindowsIdentity]::GetCurrent();
$myWindowsPrincipal = New-Object System.Security.Principal.WindowsPrincipal($myWindowsID);

# Get the security principal for the administrator role
$adminRole = [System.Security.Principal.WindowsBuiltInRole]::Administrator;

# Check to see if we are currently running as an administrator
if ($myWindowsPrincipal.IsInRole($adminRole))
{
    # We are running as an administrator, so change the title and background colour to indicate this
    $Host.UI.RawUI.WindowTitle = $myInvocation.MyCommand.Definition + "(Elevated)";
    $Host.UI.RawUI.BackgroundColor = "DarkBlue";
    Clear-Host;
}
else {
    # We are not running as an administrator, so relaunch as administrator

    # Create a new process object that starts PowerShell
    $newProcess = New-Object System.Diagnostics.ProcessStartInfo "PowerShell";

    # Specify the current script path and name as a parameter with added scope and support for scripts with spaces in it's path
    $newProcess.Arguments = "& '" + $script:MyInvocation.MyCommand.Path + "'"

    # Indicate that the process should be elevated
    $newProcess.Verb = "runas";

    # Start the new process
    [System.Diagnostics.Process]::Start($newProcess);

    # Exit from the current, unelevated, process
    Exit;
}
<# End self elevating script v1.1 #> 


<# Date-time variable v1.1 #>
$enus = 'en-US' -as [Globalization.CultureInfo]
$Date = (Get-Date).AddDays(0).ToString("MM_dd_yyyy__hh_mm_tt", $enus)
$Dt = $Date
<# End Date variable v1.1 #>


<# Creates Working Directory for Output files v1.1 #>
New-Item -ItemType Directory -Force -Path C:\PCDiag >$nullq
New-Item -ItemType Directory -Force -Path C:\PCDiag\Scripts >$nullq
New-Item -ItemType Directory -Force -Path C:\PCDiag\$Date >$nullq
New-Item -ItemType Directory -Force -Path C:\PCDiag\PSG >$nullq
<# End Working Directory #>


<# This section is used for Loading the Main Menu v1.1 #>
Clear-Host
$Host.UI.RawUI.WindowTitle = "PC Diagnostics"
function loadMainMenu()
{
    [bool]$loopMainMenu = $true
    while ($loopMainMenu)
    {
    Clear-Host  
    Write-Host -BackgroundColor Black -ForegroundColor Yellow  �`n`PC Diagnostics�
    Write-Host -ForegroundColor Yellow  �`n`tMain Menu�
    Write-Host �`t`t1 - Manual Operations�
    Write-Host �`t`t2 - Automatic Data Collection�
    Write-Host �`t`t3 - Active Directory & Domain Operations�
    Write-Host �`t`t4 - O365 Exchange Operations�
    Write-Host �`t`t5 - Local Exchange Operations�
    Write-Host �`t`t6 - Network Operations�
    Write-Host �`t`t7 - Troubleshooting Packs�
    Write-Host �`t`t8 - Powershell Gallery�
    Write-Host �`t`t9 - Download 3rd Party Utilities�
    Write-Host -ForegroundColor Green �`t`t0 - Download Required Powershell Modules�
    Write-Host -ForegroundColor Yellow �`t`tQ --- Quit And Exit`n�
    $mainMenu = Read-Host �`t`tPlease make a selection� # Get user's entry.
    switch ($mainMenu)
        {
        1{mainMenuOption1} # Calls function mainMenuOption1()
        2{mainMenuOption2} # Calls function mainMenuOption2()
        3{mainMenuOption3} # Calls function mainMenuOption3()
        4{mainMenuOption4} # Calls function mainMenuOption4()
        5{mainMenuOption5} # Calls function mainMenuOption5()
        6{mainMenuOption6} # Calls function mainMenuOption6()
        7{mainMenuOption7} # Calls function mainMenuOption7()
        8{mainMenuOption8} # Calls function mainMenuOption8()
        9{mainMenuOption9} # Calls function mainMenuOption9()
        0{mainMenuOption0} # Calls function mainMenuOption0()
           
        "q" {
                $loopMainMenu = $false
                Clear-host 
                Write-host -ForegroundColor Yellow "`n`nEnding Script Processes & Finalizing cleanup operations"
                remove-item -path C:\PCDiag\scripts -recurse
                sleep -seconds 1 
                Write-host -ForegroundColor Yellow "`n`tGoodbye!"
                sleep -Seconds 2
                $Host.UI.RawUI.WindowTitle = "Windows PowerShell" # Set back to standard.
                Clear-Host
            }
        default {
            Write-Host -BackgroundColor Red -ForegroundColor White "You did not enter a valid selection. Please enter a valid selection."
            sleep -Seconds 3
                }
        }
    }
return
}
<# End of Main Menu v1.1 #>


<# This section is used for Loading Main Menu Option 1 - Manual Operations. v1.1 #> 
function mainMenuOption1()
{
    [bool]$loopSubMenu = $true
    while ($loopSubMenu)
    {
    $Host.UI.RawUI.WindowTitle = "PC Diagnostics"
    Clear-Host  
    Write-Host -BackgroundColor Black -ForegroundColor yellow  �`n`PC Diagnostics�
    Write-Host -ForegroundColor yellow  �`n`tManual Operations�
    Write-Host �`t`t1 - Flush DNS Cache�
    Write-Host �`t`t2 - Clear ARP Cache�
    Write-Host �`t`t3 - Start SFC scan�
    Write-Host �`t`t4 - Schedule Offline CHKDSK repair on C:\�
    Write-Host �`t`t5 - Start RDP Session" Write-Host �`t`t6 - Reset Network Adapter"
    Write-Host �`t`t7 - New Menu Option 7" Write-Host -ForegroundColor Yellow �`t`tQ - Quit And Return To Main Menu`n� $subMenu = Read-Host �`t`tPlease make a selection� switch ($subMenu) { 1 {# Flush DNS Cache Clear-Host write-host -ForegroundColor yellow "`n`nFlushing DNS Resolver Cache" ipconfig /flushdns sleep -Seconds 3 } 2 {# Clear ARP Cache Clear-Host write-host -ForegroundColor yellow "`n`nClearing ARP Cache" netsh interface ip delete arpcache sleep -Seconds 3 } 3 {# Start SFC scan $SFCTITLE = '$Host.UI.RawUI.WindowTitle = "PC Diagnostics - SFC Scan"' $SFCPS1 = 'sfc /scannow' $SFCPS2 = 'Read-Host -Prompt "Press Enter to exit"' # Prevents new window from auto closing $SFCTITLE | Out-File -filepath c:\PCDiag\Scripts\SFC.ps1 $SFCPS1 | Out-File -filepath c:\PCDiag\Scripts\SFC.ps1 -append $SFCPS2 | Out-file -filepath c:\PCDiag\Scripts\SFC.ps1 -append $SFC = 'c:\PCDiag\SCripts\SFC.ps1' Clear-Host write-host "`n`nSFC scan will now Launch in a new window" sleep -Seconds 3 Start-process powershell.exe -ArgumentList "$SFC" sleep -Seconds 2 } 4 {# Schedule Offline CHKDSK repair on C:\ $CHKDSKOFFTITLE1 = '$Host.UI.RawUI.WindowTitle = "PC Diagnostics - Offline CHKDSK repair"' $CHKDSKOFFTITLE2 = '$Host.UI.RawUI.WindowTitle = "PC Diagnostics - Offline CHKDSK repair"' $CHKDSKEND = 'Read-Host -Prompt "Press Enter to exit"' # Prevents new window from auto closing $OLDCHKARG = "chkdsk /f c:" $NEWCHKARG = "chkdsk c: /OfflineScanAndFix" #Writing Script for OLDCHKDSKOFF.ps1 $CHKDSKOFFTITLE1 | Out-File -filepath c:\PCDiag\Scripts\OLDCHKDSKOFF.ps1 $OLDCHKARG | Out-File -filepath c:\PCDiag\Scripts\OLDCHKDSKOFF.ps1 -append $CHKDSKEND | Out-file -filepath c:\PCDiag\Scripts\OLDCHKDSKOFF.ps1 -append #Writing Script for NEWCHKDSKOFF.ps1 $CHKDSKOFFTITLE2 | Out-File -filepath c:\PCDiag\Scripts\NEWCHKDSKOFF.ps1 $NEWCHKARG | Out-File -filepath c:\PCDiag\Scripts\NEWCHKDSKOFF.ps1 -append $CHKDSKEND | Out-file -filepath c:\PCDiag\Scripts\NEWCHKDSKOFF.ps1 -append $OLDCHKDSK = 'c:\PCDiag\Scripts\OLDCHKDSKOFF.ps1' $NEWCHKDSK = 'c:\PCDiag\Scripts\NEWCHKDSKOFF.ps1' Clear-Host write-host "`n`nChecking Current OS version" sleep -seconds 2 #Checking OS version script $OSVER = (Get-WmiObject Win32_OperatingSystem).caption $OSNAME = $OSVER.split(" ")
            $OS = $OSNAME[2,3]
            write-host "
`n`nDetecting Current Operating system" write-host $OSNAME "Detected" write-host "`n`nA New Window will open to schedule Offline CHKDSK repair" sleep -seconds 2 If ($OS -eq "XP") { Start-process powershell.exe -ArgumentList "$OLDCHKDSK" } elseif ($OS -eq "7") { Start-process powershell.exe -ArgumentList "$OLDCHKDSK" } elseif ($OS -eq "8") { Start-process powershell.exe -ArgumentList "$NEWCHKDSK" } elseif ($OS -eq "8.1") { Start-process powershell.exe -ArgumentList "$NEWCHKDSK" } elseif ($OS -eq "10") { Start-process powershell.exe -ArgumentList "$NEWCHKDSK" } elseif ($OS -eq "2003") { Start-process powershell.exe -ArgumentList "$OLDCHKDSK" } elseif ($OS -eq "2008") { Start-process powershell.exe -ArgumentList "$OLDCHKDSK" } elseif ($OS -eq "2012") { Start-process powershell.exe -ArgumentList "$NEWCHKDSK" } elseif ($OS -eq "2016") { Start-process powershell.exe -ArgumentList "$NEWCHKDSK" } else { Write-Host "Unknown OS - " $OSNAME " Detected, Terminating Offline CHKDSK request" } sleep -seconds 7 } 5 {# Start RDP Session Start-Process "$env:windir\system32\mstsc.exe" -ArgumentList "/v:$machinename" } 6 {# Reset Network Adapter Clear-Host Write-Host -ForegroundColor yellow "`n`nResetting Network Adapter, Please wait" ipconfig /release >$nullq Sleep -Seconds 3 ipconfig /renew >$nullq } 7 {# New Menu Option 7 } q { $loopSubMenu = $false } default { Write-Host -BackgroundColor Red -ForegroundColor White "You did not enter a valid selection. Please enter a valid selection." sleep -Seconds 3 } } } } function loadmainMenuOption1() { <# End of Main Menu Option 1 - Manual Operations v1.1 #> } <# This section is used for Main Menu Option 2 - Automatic Data Collection v1.1 #> function mainMenuOption2() { [bool]$loopSubMenu = $true while ($loopSubMenu) { $Host.UI.RawUI.WindowTitle = "PC Diagnostics" Clear-Host Write-Host -BackgroundColor Black -ForegroundColor yellow �`n`PC Diagnostics� Write-Host -ForegroundColor yellow �`n`tAutomatic Data Collection� Write-Host �`t`t1 - Workstation� Write-Host �`t`t2 - Domain Controller Server� Write-Host �`t`t3 - Non Domain Controller Server� Write-Host -ForegroundColor Yellow �`t`tQ --- Quit And Return To Main Menu`n� $subMenu = Read-Host �`t`tPlease make a selection� switch ($subMenu) { 1 {# Main Sub Menu Option 1 - Automatic Data Collection - Workstation Clear-Host Write-Host -ForegroundColor yellow �`n`nAutomatic Data Collection is running, Please wait.� # List Systeminfo sleep -Seconds 1 Write-Host -ForegroundColor yellow "`n`n`tReviewing Systeminfo, details will be saved to file" systeminfo | Out-file -filepath c:\PCDiag\$Dt\Systeminfo.txt # Capture Applied GPO report sleep -Seconds 1 Write-Host -ForegroundColor yellow "`n`n`tReviewing Applied Group Policy Objects" Write-Host -ForegroundColor yellow "`tApplied Group Policy report will be saved to file" gpresult /h c:\PCDiag\$Dt\Grpresult.html # Export Error & Warning events Logs sleep -Seconds 1 Write-Host -ForegroundColor yellow "`n`n`tExporting Windows Event logs." wevtutil epl Application �/q:*[System[(Level=1 or Level=2 or Level=3)]]� C:\PCDiag\$Dt\Events_Application.evtx wevtutil epl System �/q:*[System[(Level=1 or Level=2 or Level=3)]]� C:\PCDiag\$Dt\Events_Sytem.evtx Write-Host -ForegroundColor yellow "`tWarning, Error & Critical events have been exported" #Capture IP settings to file sleep -Seconds 1 Write-Host -ForegroundColor yellow "`n`n`tCapturing IP settings, Capture complete & saved to file" ipconfig /all | out-file C:\PCDiag\$Dt\IPConfiguration.txt # List Mapped Drives sleep -Seconds 1 Write-Host -ForegroundColor yellow "`n`n`tReviewing mapped network drives, details will be saved to file" Get-WmiObject -Class Win32_MappedLogicalDisk | select Name, ProviderName | out-file c:\PCDiag\$Dt\mapped_network_drives.txt # List Domain Controllers sleep -Seconds 1 Write-Host -ForegroundColor yellow "`n`n`tPerforming query for Domain controllers, details will be saved to file" $DOMAIN = (Get-WmiObject Win32_ComputerSystem).Domain $LDOMAINTITLE = '$Host.UI.RawUI.WindowTitle = "PC Diagnostics * List Domain controllers *"' $LDOMAIN1 = "nltest /dclist:$DOMAIN | tee-object c:\PCDiag\$Dt\Domain_Controller_list.txt" $LDOMAINTITLE | Out-File -filepath c:\PCDiag\Scripts\DC_Listing.ps1 $LDOMAIN1 | Out-File -filepath c:\PCDiag\Scripts\DC_Listing.ps1 -append $LDOMAIN = 'c:\PCDiag\Scripts\DC_Listing.ps1' Start-process powershell.exe -ArgumentList "$LDOMAIN" # List Scheduled Tasks sleep -Seconds 1 Write-Host -ForegroundColor yellow "`n`n`tPerforming query for Scheduled Tasks, details will be saved to file" $schedule = new-object -com("Schedule.Service") $schedule.connect() $tasks = $schedule.getfolder("\").gettasks(0) $tasks | Format-Table Name , LastRunTime -AutoSize | out-file c:\PCDiag\$Dt\scheduled_tasks.txt IF($tasks.count -eq 0) {Write-Host �Schedule is Empty�} # List current w32tm time setting sleep -Seconds 1 Write-Host -ForegroundColor yellow "`n`n`tReviewing time settings, details will be saved to file" w32tm /query /status |out-file c:\PCDiag\$Dt\w32tm_settings.txt # New function here # End of Automatic Data Collection Write-Host -ForegroundColor yellow "`n`nAutomatic Data Collection - Completed" sleep -seconds 1 Read-Host -prompt "Press Enter to return to main Menu" # Prevents new window from auto closing sleep -seconds 1 } 2 {# Main Sub Menu Option 2 - Automatic Data Collection - Domain Controller Server Clear-Host Write-Host -ForegroundColor yellow �`n`nAutomatic Data Collection is running, Please wait.� # Run DCDIAG sleep -Seconds 1 $DCDIAGTITLE = '$Host.UI.RawUI.WindowTitle = "PC Diagnostics - DCDIAG"' $DCDIAG1 = "DCDIAG.exe /C /V | Tee-Object -file c:\PCDiag\$Dt\DCDIAG_Results.txt" $DCDIAG2 = 'Read-Host -Prompt "Press Enter to exit"' $DCDIAGTITLE | Out-File -filepath c:\PCDiag\Scripts\DCDIAG.ps1 $DCDIAG1 | Out-File -filepath c:\PCDiag\Scripts\DCDIAG.ps1 -append $DCDIAG2 | Out-file -filepath c:\PCDiag\Scripts\DCDIAG.ps1 -append $DCDIAG = 'c:\PCDiag\SCripts\DCDIAG.ps1' Start-process powershell.exe -ArgumentList "$DCDIAG" write-host -ForegroundColor yellow "`n`n`tPerforming DCDIAG scan, Results saved to file" # List Systeminfo sleep -Seconds 1 Write-Host -ForegroundColor yellow "`n`n`tReviewing Systeminfo, details will be saved to file" systeminfo | Out-file -filepath c:\PCDiag\$Dt\Systeminfo.txt # Capture Applied GPO report sleep -Seconds 1 Write-Host -ForegroundColor yellow "`n`n`tReviewing Applied Group Policy Objects" Write-Host -ForegroundColor yellow "`tApplied Group Policy report will be saved to file" gpresult /h c:\PCDiag\$Dt\Grpresult.html # Export Error & Warning events Logs sleep -Seconds 1 Write-Host -ForegroundColor yellow "`n`n`tExporting Windows Event logs." wevtutil epl Application �/q:*[System[(Level=1 or Level=2 or Level=3)]]� C:\PCDiag\$Dt\Events_Application.evtx wevtutil epl System �/q:*[System[(Level=1 or Level=2 or Level=3)]]� C:\PCDiag\$Dt\Events_Sytem.evtx Write-Host -ForegroundColor yellow "`tWarning, Error & Critical events have been exported" # Capture IP settings to file sleep -Seconds 1 Write-Host -ForegroundColor yellow "`n`n`tCapturing IP settings, Capture complete & saved to file" ipconfig /all | out-file C:\PCDiag\$Dt\IPConfiguration.txt # List Mapped Drives sleep -Seconds 1 Write-Host -ForegroundColor yellow "`n`n`tReviewing mapped network drives, details will be saved to file" Get-WmiObject -Class Win32_MappedLogicalDisk | select Name, ProviderName | out-file c:\PCDiag\$Dt\mapped_network_drives.txt # List Domain Controllers sleep -Seconds 1 Write-Host -ForegroundColor yellow "`n`n`tPerforming query for Domain controllers, details will be saved to file" $DOMAIN = (Get-WmiObject Win32_ComputerSystem).Domain $LDOMAINTITLE = '$Host.UI.RawUI.WindowTitle = "PC Diagnostics * List Domain controllers *"' $LDOMAIN1 = "nltest /dclist:$DOMAIN | tee-object c:\PCDiag\$Dt\Domain_Controller_list.txt" $LDOMAINTITLE | Out-File -filepath c:\PCDiag\Scripts\DC_Listing.ps1 $LDOMAIN1 | Out-File -filepath c:\PCDiag\Scripts\DC_Listing.ps1 -append $LDOMAIN = 'c:\PCDiag\Scripts\DC_Listing.ps1' Start-process powershell.exe -ArgumentList "$LDOMAIN" # List Server Roles sleep -Seconds 1 Import-module servermanager ; Get-WindowsFeature | out-file c:\PCDiag\$Dt\Server_Roles.txt write-host -ForegroundColor yellow "`n`n`tCapturing Installed server roles, Results saved to file" # List FSMO roles sleep -Seconds 1 $FSMOTITLE = '$Host.UI.RawUI.WindowTitle = "PC Diagnostics - List FSMO roles"' $FSMO1 = "netdom query fsmo | Tee-Object -file c:\PCDiag\$Dt\FSMO_Results.txt" $FSMOTITLE | Out-File -filepath c:\PCDiag\Scripts\FSMO.ps1 $FSMO1 | Out-File -filepath c:\PCDiag\Scripts\FSMO.ps1 -append $FSMO = 'c:\PCDiag\SCripts\FSMO.ps1' Start-process powershell.exe -ArgumentList "$FSMO" write-host -ForegroundColor yellow "`n`n`tCapturing FSMO role assignments, Results saved to file" sleep -Seconds 2 # List Scheduled Tasks sleep -Seconds 1 Write-Host -ForegroundColor yellow "`n`n`tPerforming query for Scheduled Tasks, details will be saved to file" $schedule = new-object -com("Schedule.Service") $schedule.connect() $tasks = $schedule.getfolder("\").gettasks(0) $tasks | Format-Table Name , LastRunTime -AutoSize | out-file c:\PCDiag\$Dt\scheduled_tasks.txt IF($tasks.count -eq 0) {Write-Host �Schedule is Empty�} # List current w32tm time setting sleep -Seconds 1 Write-Host -ForegroundColor yellow "`n`n`tReviewing time settings, details will be saved to file" w32tm /query /status |out-file c:\PCDiag\$Dt\w32tm_settings.txt # New Function here # End of Automatic Data Collection Write-Host -ForegroundColor yellow "`n`nAutomatic Data Collection - Completed" sleep -seconds 1 Read-Host -prompt "Press Enter to return to main Menu" # Prevents new window from auto closing sleep -seconds 1 } 3 {# Main Sub Menu Option 3 - Automatic Data Collection - Non Domain Controller Server Clear-Host Write-Host -ForegroundColor yellow �`n`nAutomatic Data Collection is running, Please wait.� # List Systeminfo sleep -Seconds 1 Write-Host -ForegroundColor yellow "`n`n`tReviewing Systeminfo, details will be saved to file" systeminfo | Out-file -filepath c:\PCDiag\$Dt\Systeminfo.txt # Capture Applied GPO report sleep -Seconds 1 Write-Host -ForegroundColor yellow "`n`n`tReviewing Applied Group Policy Objects" Write-Host -ForegroundColor yellow "`tApplied Group Policy report will be saved to file" gpresult /h c:\PCDiag\$Dt\Grpresult.html # Export Error & Warning events Logs sleep -Seconds 1 Write-Host -ForegroundColor yellow "`n`n`tExporting Windows Event logs." wevtutil epl Application �/q:*[System[(Level=1 or Level=2 or Level=3)]]� C:\PCDiag\$Dt\Events_Application.evtx wevtutil epl System �/q:*[System[(Level=1 or Level=2 or Level=3)]]� C:\PCDiag\$Dt\Events_Sytem.evtx Write-Host -ForegroundColor yellow "`tWarning, Error & Critical events have been exported" #Capture IP settings to file sleep -Seconds 1 Write-Host -ForegroundColor yellow "`n`n`tCapturing IP settings, Capture complete & saved to file" ipconfig /all | out-file C:\PCDiag\$Dt\IPConfiguration.txt # List Mapped Drives sleep -Seconds 1 Write-Host -ForegroundColor yellow "`n`n`tReviewing mapped network drives, details will be saved to file" Get-WmiObject -Class Win32_MappedLogicalDisk | select Name, ProviderName | out-file c:\PCDiag\$Dt\mapped_network_drives.txt # List Domain Controllers sleep -Seconds 1 Write-Host -ForegroundColor yellow "`n`n`tPerforming query for Domain controllers, details will be saved to file" $DOMAIN = (Get-WmiObject Win32_ComputerSystem).Domain $LDOMAINTITLE = '$Host.UI.RawUI.WindowTitle = "PC Diagnostics * List Domain controllers *"' $LDOMAIN1 = "nltest /dclist:$DOMAIN | tee-object c:\PCDiag\$Dt\Domain_Controller_list.txt" $LDOMAINTITLE | Out-File -filepath c:\PCDiag\Scripts\DC_Listing.ps1 $LDOMAIN1 | Out-File -filepath c:\PCDiag\Scripts\DC_Listing.ps1 -append $LDOMAIN = 'c:\PCDiag\Scripts\DC_Listing.ps1' Start-process powershell.exe -ArgumentList "$LDOMAIN" # List Server Roles sleep -Seconds 1 Import-module servermanager ; Get-WindowsFeature | out-file c:\PCDiag\$Dt\Server_Roles.txt write-host -ForegroundColor yellow "`n`n`tCapturing Installed server roles, Results saved to file" # List FSMO roles sleep -Seconds 1 $FSMOTITLE = '$Host.UI.RawUI.WindowTitle = "PC Diagnostics - List FSMO roles"' $FSMO1 = "netdom query fsmo | Tee-Object -file c:\PCDiag\$Dt\FSMO_Results.txt" $FSMOTITLE | Out-File -filepath c:\PCDiag\Scripts\FSMO.ps1 $FSMO1 | Out-File -filepath c:\PCDiag\Scripts\FSMO.ps1 -append $FSMO = 'c:\PCDiag\SCripts\FSMO.ps1' Start-process powershell.exe -ArgumentList "$FSMO" write-host -ForegroundColor yellow "`n`n`tCapturing FSMO role assignments, Results saved to file" sleep -Seconds 2 # List Scheduled Tasks sleep -Seconds 1 Write-Host -ForegroundColor yellow "`n`n`tPerforming query for Scheduled Tasks, details will be saved to file" $schedule = new-object -com("Schedule.Service") $schedule.connect() $tasks = $schedule.getfolder("\").gettasks(0) $tasks | Format-Table Name , LastRunTime -AutoSize | out-file c:\PCDiag\$Dt\scheduled_tasks.txt IF($tasks.count -eq 0) {Write-Host �Schedule is Empty�} # List current w32tm time setting sleep -Seconds 1 Write-Host -ForegroundColor yellow "`n`n`tReviewing time settings, details will be saved to file" w32tm /query /status |out-file c:\PCDiag\$Dt\w32tm_settings.txt # New function here # End of Automatic Data Collection Write-Host -ForegroundColor yellow "`n`nAutomatic Data Collection Completed" sleep -seconds 1 Read-Host -prompt "Press Enter to return to main Menu" # Prevents new window from auto closing sleep -seconds 1 } q { $loopSubMenu = $false } default { Write-Host -BackgroundColor Red -ForegroundColor White "You did not enter a valid selection. Please enter a valid selection." sleep -Seconds 3 } } } } function loadmainMenuOption2() { <# End of Main Menu Option 2 - Automatic Data Collection v1.1 #> } <# This section is used for Loading Main Menu Option 3 - Active Directory & Domain Operations. v1.1 #> function mainMenuOption3() { Import-Module activedirectory [bool]$loopSubMenu = $true while ($loopSubMenu) { $Host.UI.RawUI.WindowTitle = "PC Diagnostics" Clear-Host Write-Host -BackgroundColor Black -ForegroundColor yellow �`n`PC Diagnostics� Write-Host -ForegroundColor yellow �`n`tActive Directory & Domain Operations� Write-Host �`t`t1 - List Users� Write-Host �`t`t2 - List Computers� Write-Host �`t`t3 - List Computers Last Logon Date� Write-Host �`t`t4 - Export all GPO settings� Write-Host �`t`t5 - List all GPO properties� Write-Host �`t`t6 - List Active Certificate Authority� Write-Host �`t`t7 - New Menu Option 7� Write-Host -ForegroundColor Yellow �`t`tQ --- Quit And Return To Main Menu`n� $subMenu = Read-Host �`t`tPlease make a selection� switch ($subMenu) { 1 {# List Users $ADLUTITLE = '$Host.UI.RawUI.WindowTitle = "PC Diagnostics - Active Directory - List Users"' $ADLU1 = "Get-ADUser -filter * | sort-object | out-file c:\PCDiag\$Dt\AD_Users.txt" $ADLUTITLE | Out-File -filepath c:\PCDiag\Scripts\ADLU.ps1 $ADLU1 | Out-File -filepath c:\PCDiag\Scripts\ADLU.ps1 -append $ADLU = 'c:\PCDiag\SCripts\ADLU.ps1' Clear-Host Write-host -ForegroundColor yellow "Reviewing Active Directory Users, Results saved to file" Start-process powershell.exe -ArgumentList "$ADLU" Sleep -Seconds 2 } 2 {# List Computers $ADLCTITLE = '$Host.UI.RawUI.WindowTitle = "PC Diagnostics - PC Diagnostics - Active Directory - List computers"' $ADLC1 = "Get-ADComputer -Filter * -Property * | sort-object | Format-Table Name,OperatingSystem,OperatingSystemServicePack,OperatingSystemVersion -Wrap �Auto | out-file c:\PCDiag\$Dt\AD_Computers.txt" $ADLCTITLE | Out-File -filepath c:\PCDiag\Scripts\ADLC.ps1 $ADLC1 | Out-File -filepath c:\PCDiag\Scripts\ADLC.ps1 -append $ADLC = 'c:\PCDiag\SCripts\ADLC.ps1' Clear-Host write-host -ForegroundColor yellow "Reviewing Active Directory computers, Results saved to file" Start-process powershell.exe -ArgumentList "$ADLC" sleep -Seconds 2 } 3 {# List Computers Last Logon Date $ADLGOTITLE = '$Host.UI.RawUI.WindowTitle = "PC Diagnostics - PC Diagnostics - Active Directory - List Computers Last Logon Date"' $ADLGO1 = "Get-ADComputer -Filter * -Properties * |sort-object lastlogondate -descending | FT name,lastlogondate -Autosize | out-file c:\PCDiag\$Dt\AD_Lastlogon_Computers.txt" $ADLGOTITLE | Out-File -filepath c:\PCDiag\Scripts\ADLGO.ps1 $ADLGO1 | Out-File -filepath c:\PCDiag\Scripts\ADLGO.ps1 -append $ADLGO = 'c:\PCDiag\SCripts\ADLGO.ps1' Clear-Host write-host -ForegroundColor yellow "Reviewing Last Logon Date for Active Directory computers, Results saved to file" Start-process powershell.exe -ArgumentList "$ADLGO" sleep -Seconds 2 } 4 {# Export all GPO settings Clear-Host write-host -ForegroundColor yellow "Reviewing all GPO's and generating report, Results saved to file" Get-GPOReport -All -ReportType HTML -Path c:\PCDiag\$Dt\All_GPO_settings.html Sleep -Seconds 2 } 5 {# List all GPO properties Clear-Host write-host -ForegroundColor yellow "Reviewing all GPO's and generating report, Results saved to file" Get-GPO -all | select-object -Property DisplayName,ID,gpostatus |sort-object Displayname | format-table |out-file c:\PCDiag\$Dt\GPOproperties.txt Sleep -Seconds 2 } 6 {# List Active Certificate Authority Clear-Host write-host -ForegroundColor yellow "`n`nSearching for Active Certificate Authority, Results saved to file" sleep -seconds 1 certutil -config - -ping | out-file c:\PCDiag\$Dt\Certificate_Authority.txt Sleep -Seconds 2 } 7 {# New Menu Option 7 } q { $loopSubMenu = $false } default { Write-Host -BackgroundColor Red -ForegroundColor White "You did not enter a valid selection. Please enter a valid selection." sleep -Seconds 3 } } } } function loadSubMenu1Option3() { <# End of Main Menu Option 5 - Active Directory & Domain Operations. v1.1 #> } <# This section is used for Loading Main Menu Option 6 - O365 Exchange Operations. v1.1 #> function mainMenuOption4() { Import-Module msonline [bool]$loopSubMenu = $true while ($loopSubMenu) { $Host.UI.RawUI.WindowTitle = "PC Diagnostics" Clear-Host Write-Host -BackgroundColor Black -ForegroundColor yellow �`n`PC Diagnostics� Write-Host -ForegroundColor yellow �`n`tO365 Exchange Operations� Write-Host �`t`t1 - Enter 0365 credentials� Write-Host �`t`t2 - List Assigned licenses� Write-Host �`t`t3 - O365 Report� Write-Host �`t`t4 - Disable Clutter All Users� Write-Host �`t`t5 - New Menu Option 5� Write-Host -ForegroundColor Yellow �`t`tQ --- Quit And Return To Main Menu`n� $subMenu = Read-Host �`t`tPlease make a selection� switch ($subMenu) { 1 {# Connect to O365 Clear-Host sleep -Seconds 1 write-host -ForegroundColor yellow "Enter O365 Login Credentials" $O365UserCredential = Get-Credential } 2 {# List Assigned licenses Clear-Host sleep -Seconds 1 write-host -ForegroundColor yellow "Capturing assigned license information" connect-msolservice -credential $O365UserCredential Get-MSOLUser -all | where-object {$_.isLicensed -eq "FALSE" } | select userprincipalname,DisplayName |sort-object | out-file c:\PCDiag\$Dt\exchange_assignedlicense.txt write-host -ForegroundColor yellow "Capture completed, details saved to file" sleep -Seconds 2 } 3 {# O365 Report Clear-Host sleep -Seconds 1 write-host -ForegroundColor yellow "Running O365 report" Connect-MsolService -Credential $O365UserCredential $O365Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $O365UserCredential -Authentication Basic -AllowRedirection Import-PSSession $O365Session $Report=@() $Mailboxes = Get-Mailbox -ResultSize Unlimited | where {$_.RecipientTypeDetails -ne "DiscoveryMailbox"} $MSOLDomain = Get-MsolDomain | where {$_.Authentication -eq "Managed" -and $_.IsDefault -eq "True"} $MSOLPasswordPolicy = Get-MsolPasswordPolicy -DomainName $MSOLDomain.name $MSOLPasswordPolicy = $MSOLPasswordPolicy.ValidityPeriod.ToString() foreach ($mailbox in $Mailboxes) { $DaysToExpiry = @() $DisplayName = $mailbox.DisplayName $UserPrincipalName = $mailbox.UserPrincipalName $UserDomain = $UserPrincipalName.Split('@')[1] $Alias = $mailbox.alias $MailboxStat = Get-MailboxStatistics $UserPrincipalName $LastLogonTime = $MailboxStat.LastLogonTime $TotalItemSize = $MailboxStat | select @{name="TotalItemSize";expression={[math]::Round(($_.TotalItemSize.ToString().Split("(")[1].Split(" ")[0].Replace(",","")/1MB),2)}}
            $TotalItemSize = $TotalItemSize.TotalItemSize
            $RecipientTypeDetails = $mailbox.RecipientTypeDetails
            $MSOLUSER = Get-MsolUser -UserPrincipalName $UserPrincipalName
            if ($UserDomain -eq $MSOLDomain.name) {$DaysToExpiry = $MSOLUSER | select @{Name="
DaysToExpiry"; Expression={(New-TimeSpan -start (get-date) -end ($_.LastPasswordChangeTimestamp + $MSOLPasswordPolicy)).Days}}; $DaysToExpiry = $DaysToExpiry.DaysToExpiry} $Information = $MSOLUSER | select FirstName,LastName,@{Name='DisplayName'; Expression={[String]::join(";", $DisplayName)}},@{Name='Alias'; Expression={[String]::join(";", $Alias)}},@{Name='UserPrincipalName'; Expression={[String]::join(";", $UserPrincipalName)}},Office,Department,@{Name='TotalItemSize (MB)'; Expression={[String]::join(";", $TotalItemSize)}},@{Name='LastLogonTime'; Expression={[String]::join(";", $LastLogonTime)}},LastPasswordChangeTimestamp,@{Name="PasswordExpirationIn (Days)"; Expression={[String]::join(";", $DaysToExpiry)}},@{Name='RecipientTypeDetails'; Expression={[String]::join(";", $RecipientTypeDetails)}},islicensed,@{Name="Licenses"; Expression ={$_.Licenses.AccountSkuId}} $Report = $Report+$Information } $Report | export-csv c:\PCDiag\$Dt\O365Report.csv Get-PSSession | Remove-PSSession write-host -ForegroundColor yellow "Report Complete, details saved to file" sleep -Seconds 2 } 4 {# Disable Clutter for All Users Clear-Host sleep -Seconds 1 write-host -ForegroundColor yellow "Disabling Clutter for All Users" connect-msolservice -credential $0365UserCredential Get-Mailbox | Set-Clutter -Enable $false write-host -ForegroundColor yellow "Process Complete, Clutter Disabled for all users" sleep -Seconds 2 } 5 {# New Menu Option 5 } q { $loopSubMenu = $false } default { Write-Host -BackgroundColor Red -ForegroundColor White "You did not enter a valid selection. Please enter a valid selection." sleep -Seconds 3 } } } } function loadSubMenu1Option4() { <# End of Main Menu Option 4 - 0365 Exchange Operations. v1.1 #> } <# This section is used for Loading Main Menu Option 5 - Local Exchange Operations v1.1 #> function mainMenuOption5() { [bool]$loopSubMenu = $true while ($loopSubMenu) { $Host.UI.RawUI.WindowTitle = "PC Diagnostics" Clear-Host Write-Host -BackgroundColor Black -ForegroundColor yellow �`n`PC Diagnostics� Write-Host -ForegroundColor yellow �`n`tLocal Exchange Operations� Write-Host �`t`t1 - Exchange 2007� Write-Host �`t`t2 - Exchange 2010� Write-Host �`t`t3 - Exchange 2013� Write-Host -ForegroundColor Yellow �`t`tQ --- Quit And Return To Main Menu`n� $subMenu = Read-Host �`t`tPlease make a selection� switch ($subMenu) { 1 {# Exchange 2007 <# This section is used for Loading Sub Menu Option 1 - Exchange 2007 v1.1 #> function loadSublvlMenu() { [bool]$loopSublvlMenu = $true while ($loopSublvlMenu) { Clear-Host Write-Host -BackgroundColor Black -ForegroundColor Yellow �`n`PC Diagnostics� Write-Host -ForegroundColor Yellow �`n`tExchange 2007� Write-Host �`t`t1 - Connect to local Exchange server� Write-Host �`t`t2 - List all SMTP email addresses� Write-Host �`t`t3 - New Sub Menu Option 3� Write-Host -ForegroundColor Yellow �`t`tQ --- Quit And Return To Previous Menu`n� $sublvlMenu = Read-Host �`t`tPlease make a selection� # Get user's entry. switch ($sublvlMenu) { 1 {# Connect to Exchange Clear-Host Write-Host -ForegroundColor Yellow "`n`n`tEstablishing connection to local Exchange server" $Domain = �LDAP://�+([ADSI]��).distinguishedName $domsplit = $domain.split("=" + ",")
                    $curdom = $domsplit[1]
                    $domuser = read-host "
`n`tEnter authorized administrator User Name" $dompassword = read-host "`n`tEnter Password" | ConvertTo-SecureString -AsPlainText -Force $Exch2007creds = $curdom + "\" + $domuser $cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $Exch2007creds, $dompassword $domainforest = get-adforest | select -ExpandProperty Name $servername = read-host "`n`tEnter name of Exchange server" $exch2007server = $servername + "." + $domainforest $Ex2007Session = New-PSSession �ConfigurationName Microsoft.Exchange �ConnectionUri "http://$exch2007server/PowerShell" -Credential $cred �Authentication Kerberos Import-PSSession $Ex2007Session Write-Host -ForegroundColor Green "`n`tConnected to local Exchange server" sleep -seconds 3 } 2 {# List all SMTP email addresses Clear-Host Write-Host -ForegroundColor yellow "Performing query for all SMTP email addresses, please wait" Get-Recipient | Select Name -ExpandProperty EmailAddresses | Select Name, SmtpAddress | out-file c:\PCDiag\$Dt\All_SMTP_email_addresses.txt Write-Host -ForegroundColor yellow "Query completed, results saved to file" sleep -seconds 2 } 3 {# New Menu Option 3 } q { $loopSublvlMenu = $false } default { Write-Host -BackgroundColor Red -ForegroundColor White "You did not enter a valid selection. Please enter a valid selection." sleep -Seconds 3 } } } return } # Start the Sub Menu once loaded: loadSublvlMenu <# End of Sub Menu Option 1 - Exchange 2007 v1.1 #> } 2 {# Exchange 2010 <# This section is used for Loading Sub Menu Option 2 - Exchange 2010 v1.1 #> function loadSublvlMenu() { [bool]$loopSublvlMenu = $true while ($loopSublvlMenu) { Clear-Host Write-Host -BackgroundColor Black -ForegroundColor Yellow �`n`PC Diagnostics� Write-Host -ForegroundColor Yellow �`n`tExchange 2010� Write-Host �`t`t1 - Connect to local Exchange server� Write-Host �`t`t2 - List all SMTP email addresses� Write-Host �`t`t3 - New Sub Menu Option 3� Write-Host -ForegroundColor Yellow �`t`tQ --- Quit And Return To Previous Menu`n� $sublvlMenu = Read-Host �`t`tPlease make a selection� # Get user's entry. switch ($sublvlMenu) { 1 {# Connect to local Exchange server Clear-Host Write-Host -ForegroundColor Yellow "`n`n`tEstablishing connection to local Exchange server" $Domain = �LDAP://�+([ADSI]��).distinguishedName $domsplit = $domain.split("=" + ",")
                    $curdom = $domsplit[1]
                    $domuser = read-host "
`n`tEnter authorized administrator User Name" $dompassword = read-host "`n`tEnter Password" | ConvertTo-SecureString -AsPlainText -Force $Exch2010creds = $curdom + "\" + $domuser $cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $Exch2010creds, $dompassword $domainforest = get-adforest | select -ExpandProperty Name $servername = read-host "`n`tEnter name of Exchange server" $exch2010server = $servername + "." + $domainforest $ex2010Session = New-PSSession �ConfigurationName Microsoft.Exchange �ConnectionUri "http://$exch2010server/PowerShell" -Credential $cred �Authentication Kerberos Import-PSSession $ex2010Session Write-Host -ForegroundColor Green "`n`tConnected to local Exchange server" sleep -seconds 3 } 2 {# List all SMTP email addresses Clear-Host Write-Host -ForegroundColor yellow "Performing query for all SMTP email addresses, please wait" Get-Recipient | Select Name -ExpandProperty EmailAddresses | Select Name, SmtpAddress | out-file c:\PCDiag\$Dt\All_SMTP_email_addresses.txt Write-Host -ForegroundColor yellow "Query completed, results saved to file" sleep -seconds 2 } 3 {# Mailbox Statistics $Mailboxes = Get-Mailbox -ResultSize Unlimited foreach ($Mailbox in $Mailboxes) {$Mailbox | Add-Member -MemberType "NoteProperty" -Name "MailboxSizeMB" -Value ((Get-MailboxStatistics $Mailbox).TotalItemSize.Value.ToMb())} $Mailboxes | Sort-Object MailboxSizeMB -Desc | Select DisplayName, Alias, PrimarySMTPAddress, MailboxSizeMB | Export-Csv -NoType "c:\PCDiag\$Dt\Mailboxes.csv" } q { $loopSublvlMenu = $false } default { Write-Host -BackgroundColor Red -ForegroundColor White "You did not enter a valid selection. Please enter a valid selection." sleep -Seconds 3 } } } return } # Start the Sub Menu once loaded: loadSublvlMenu <# End of Sub Menu Option 2 - Exchange 2010 v1.1 #> } 3 {# Exchange 2013 <# This section is used for Loading Sub level Menu Option 3 - Exchange 2013 v1.1 #> function loadSublvlMenu() { [bool]$loopSublvlMenu = $true while ($loopSublvlMenu) { Clear-Host Write-Host -BackgroundColor Black -ForegroundColor Yellow �`n`PC Diagnostics� Write-Host -ForegroundColor Yellow �`n`tExchange 2013� Write-Host �`t`t1 - Connect to local Exchange server� Write-Host �`t`t2 - New Sub Menu Option 2� Write-Host �`t`t3 - New Sub Menu Option 3� Write-Host -ForegroundColor Yellow �`t`tQ --- Quit And Return To Previous Menu`n� $sublvlMenu = Read-Host �`t`tPlease make a selection� # Get user's entry. switch ($sublvlMenu) { 1 {# Connect to local Exchange server Clear-Host Write-Host -ForegroundColor Red "`n`n`tEstablishing connection to local Exchange server" $Domain = �LDAP://�+([ADSI]��).distinguishedName $domsplit = $domain.split("=" + ",")
                    $curdom = $domsplit[1]
                    $domuser = read-host "
`n`tEnter authorized administrator User Name" $dompassword = read-host "`n`tEnter Password" | ConvertTo-SecureString -AsPlainText -Force $Exch2013creds = $curdom + "\" + $domuser $cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $Exch2013creds, $dompassword $domainforest = get-adforest | select -ExpandProperty Name $servername = read-host "`n`tEnter name of Exchange server" $exch2013server = $servername + "." + $domainforest $ex2013Session = New-PSSession �ConfigurationName Microsoft.Exchange �ConnectionUri "http://$exch2013server/PowerShell" -Credential $cred �Authentication Kerberos Import-PSSession $ex2013Session Write-Host -ForegroundColor Green "`n`tConnected to local Exchange server" sleep -seconds 3 } 2 {# New Menu Option 2 } 3 {# New Menu Option 3 } q { $loopSublvlMenu = $false } default { Write-Host -BackgroundColor Red -ForegroundColor White "You did not enter a valid selection. Please enter a valid selection." sleep -Seconds 3 } } } return } # Start the Sub Menu once loaded: loadSublvlMenu <# End of Sub level Menu Option 3 - Exchange 2013 v1.1 #> } q { $loopSubMenu = $false } default { Write-Host -BackgroundColor Red -ForegroundColor White "You did not enter a valid selection. Please enter a valid selection." sleep -Seconds 3 } } } } function loadSubMenu1Option5() { <# End of Main Menu Option 5 - Local Exchange Operations v1.1 #> } <# This section is used for Loading Main Menu Option 6 - Network Operations V1.1 #> function mainMenuOption6() { [bool]$loopSubMenu = $true while ($loopSubMenu) { $Host.UI.RawUI.WindowTitle = "PC Diagnostics" Clear-Host Write-Host -BackgroundColor Black -ForegroundColor yellow �`n`PC Diagnostics� Write-Host -ForegroundColor yellow �`n`tNetwork Operations� Write-Host �`t`t1 - New Menu Option 1� Write-Host �`t`t2 - New Menu Option 2� Write-Host �`t`t3 - New Menu Option 3� Write-Host -ForegroundColor Yellow �`t`tQ --- Quit And Return To Main Menu`n� $subMenu = Read-Host �`t`tPlease make a selection� switch ($subMenu) { 1 {# New Menu Option 1 } 2 {# New Menu Option 3 } 3 {# New Menu Option 3 } q { $loopSubMenu = $false } default { Write-Host -BackgroundColor Red -ForegroundColor White "You did not enter a valid selection. Please enter a valid selection." sleep -Seconds 3 } } } } function loadSubMenu1Option6() { <# End of Main Menu Option 6 - Network Operations v1.1 #> } <# This section is used for Loading Main Menu Option 7 - TroubleShooting Packs v1.1 #> function mainMenuOption7() { Import-Module troubleshootingpack [bool]$loopSubMenu = $true while ($loopSubMenu) { $Host.UI.RawUI.WindowTitle = "PC Diagnostics" Clear-Host Write-Host -BackgroundColor Black -ForegroundColor yellow �`n`PC Diagnostics� Write-Host -ForegroundColor yellow �`n`tTroubleShooting Packs� Write-Host �`t`t1 - AERO Test� Write-Host �`t`t2 - APPS Test� Write-Host �`t`t3 - Audio Test� Write-Host �`t`t4 - BITS Test� Write-Host �`t`t5 - Blue Screen Test� Write-Host �`t`t6 - Device Test� Write-Host �`t`t7 - Device Center Test� Write-Host �`t`t8 - IE Browse Web Test� Write-Host �`t`t9 - IE Security Test� Write-Host �`t`t10 - Keyboard Test"
    Write-Host �`t`t11 - Networking Test" Write-Host �`t`t12 - Performance Counters Test" 
    Write-Host �`t`t13 - Performance Test" Write-Host �`t`t14 - Power Test"
    Write-Host �`t`t15 - Printer Test" Write-Host �`t`t16 - Search Test" 
    Write-Host �`t`t17 - Usb Core Test" Write-Host �`t`t18 - Video Test"
    Write-Host �`t`t19 - Windows Update Test" Write-Host -ForegroundColor Yellow �`t`tQ - Quit And Return To Main Menu`n� $subMenu = Read-Host �`t`tPlease make a selection� switch ($subMenu) { 1 {# Aero Test Clear-Host Write-Host -ForegroundColor yellow "`n`nLaunching AERO Troubleshooting pack" Get-TroubleshootingPack C:\Windows\diagnostics\system\AERO | Invoke-TroubleshootingPack sleep -seconds 1 } 2 {# APPS Test Clear-Host write-host -ForegroundColor yellow "`n`nLaunching Apps Troubleshooting pack" sleep -Seconds 1 Get-TroubleshootingPack C:\Windows\diagnostics\system\Apps | Invoke-TroubleshootingPack sleep -Seconds 1 } 3 {# Audio Test Clear-Host write-host -ForegroundColor yellow "`n`nLaunching Audio Troubleshooting pack" sleep -Seconds 1 Get-TroubleshootingPack C:\Windows\diagnostics\system\Audio | Invoke-TroubleshootingPack sleep -Seconds 1 } 4 {# BITS Test Clear-Host write-host -ForegroundColor yellow "`n`nLaunching BITS Troubleshooting pack" sleep -Seconds 1 Get-TroubleshootingPack C:\Windows\diagnostics\system\BITS | Invoke-TroubleshootingPack sleep -Seconds 1 } 5 {# Blue Screen Test Clear-Host write-host -ForegroundColor yellow "`n`nLaunching Blue Screen Troubleshooting pack" sleep -Seconds 1 Get-TroubleshootingPack C:\Windows\diagnostics\system\Bluescreen | Invoke-TroubleshootingPack sleep -Seconds 1 } 6 {# Device Test Clear-Host write-host -ForegroundColor yellow "`n`nLaunching Device Troubleshooting pack" sleep -Seconds 1 Get-TroubleshootingPack C:\Windows\diagnostics\system\Device | Invoke-TroubleshootingPack sleep -Seconds 3 } 7 {# Device Center Test Clear-Host write-host -ForegroundColor yellow "`n`nLaunching Device Center Troubleshooting pack" sleep -Seconds 1 Get-TroubleshootingPack C:\Windows\diagnostics\system\DeviceCenter | Invoke-TroubleshootingPack sleep -Seconds 3 } 8 {#IE Browse Web Test Clear-Host write-host -ForegroundColor yellow "`n`nLaunching IE Browse Web Troubleshooting pack" sleep -Seconds 1 Get-TroubleshootingPack C:\Windows\diagnostics\system\IEBrowseWeb | Invoke-TroubleshootingPack sleep -Seconds 1 } 9 {# IE Security Test Clear-Host write-host -ForegroundColor yellow "`n`nLaunching IE Security Troubleshooting pack" sleep -Seconds 1 Get-TroubleshootingPack C:\Windows\diagnostics\system\IESecurity | Invoke-TroubleshootingPack sleep -Seconds 1 } 10 {#Keyboard Test Clear-Host write-host -ForegroundColor yellow "`n`nLaunching Keyboard Troubleshooting pack" sleep -Seconds 1 Get-TroubleshootingPack C:\Windows\diagnostics\system\Keyboard | Invoke-TroubleshootingPack sleep -Seconds 1 } 11 {# Networking Test Clear-Host write-host -ForegroundColor yellow "`n`nLaunching Networking Troubleshooting pack" write-host -ForegroundColor yellow 'PRESS ENTER at : to bring up menu' sleep -Seconds 1 Get-TroubleshootingPack C:\Windows\diagnostics\system\Networking | Invoke-TroubleshootingPack sleep -Seconds 1 } 12 {# Performance Counters Test Clear-Host write-host -ForegroundColor yellow "`n`nLaunching Performance Counters Troubleshooting pack" sleep -Seconds 1 Get-TroubleshootingPack C:\Windows\diagnostics\system\PCW | Invoke-TroubleshootingPack sleep -Seconds 1 } 13 {#Performance Test Clear-Host write-host -ForegroundColor yellow "`n`nLaunching Performance Troubleshooting pack" sleep -Seconds 1 Get-TroubleshootingPack C:\Windows\diagnostics\system\Performance | Invoke-TroubleshootingPack sleep -Seconds 1 } 14 {#Power Test Clear-Host write-host -ForegroundColor yellow "`n`nLaunching Power Troubleshooting pack" sleep -Seconds 1 Get-TroubleshootingPack C:\Windows\diagnostics\system\Power | Invoke-TroubleshootingPack sleep -Seconds 1 } 15 {# Printer Test Clear-Host write-host -ForegroundColor yellow "`n`nLaunching Printer Troubleshooting pack" sleep -Seconds 1 Get-TroubleshootingPack C:\Windows\diagnostics\system\Printer | Invoke-TroubleshootingPack sleep -Seconds 1 } 16 {# Search Test Clear-Host write-host -ForegroundColor yellow "`n`nLaunching Search Troubleshooting pack" sleep -Seconds 1 Get-TroubleshootingPack C:\Windows\diagnostics\system\Search | Invoke-TroubleshootingPack sleep -Seconds 1 } 17 {# Usb Core Test Clear-Host write-host -ForegroundColor yellow "`n`nLaunching Usb Core Troubleshooting pack" sleep -Seconds 1 Get-TroubleshootingPack C:\Windows\diagnostics\system\UsbCore | Invoke-TroubleshootingPack sleep -Seconds 1 } 18 {# Video Test Clear-Host write-host -ForegroundColor yellow "`n`nLaunching Video Troubleshooting pack" sleep -Seconds 1 Get-TroubleshootingPack C:\Windows\diagnostics\system\Video | Invoke-TroubleshootingPack sleep -Seconds 1 } 19 {# Windows Update Test Clear-Host write-host -ForegroundColor yellow "`n`nLaunching Windows Update Troubleshooting pack" sleep -Seconds 1 Get-TroubleshootingPack C:\Windows\diagnostics\system\WindowsUpdate | Invoke-TroubleshootingPack sleep -Seconds 1 } q { $loopSubMenu = $false } default { Write-Host -BackgroundColor Red -ForegroundColor White "You did not enter a valid selection. Please enter a valid selection." sleep -Seconds 3 } } } } function loadSubMenu1Option7() { <# End of Sub Menu 7 - TroubleShooting Packs. v1.1 #> } # This section is used for Loading Main Menu Option 8 - Powershell Gallery v1.1. function mainMenuOption8() { [bool]$loopSubMenu = $true while ($loopSubMenu) { $Host.UI.RawUI.WindowTitle = "PC Diagnostics" Clear-Host Write-Host -BackgroundColor Black -ForegroundColor yellow �`n`PC Diagnostics� Write-Host -ForegroundColor yellow �`n`tPowershell Gallery� Write-Host �`t`t1 - Search gallery for script� Write-Host �`t`t2 - New Menu Option 2� Write-Host -ForegroundColor Yellow �`t`tQ --- Quit And Return To Main Menu`n� $subMenu = Read-Host �`t`tPlease make a selection� switch ($subMenu) { 1 {# Search gallery for script Clear-Host Write-host -ForegroundColor yellow "`n`n`tConnecting to Microsoft Powershell Gallery" Write-host -ForegroundColor yellow "`n`t*WARNING* These scripts are not part of the PCDiag script, use at your own risk. *WARNING*" Sleep -Seconds 3 Write-Host -ForegroundColor yellow "`n`n`n`n`tTo search the gallery please enter a keyword to start searching, Results will output to a new window" $PSGKEYWORD = Read-Host "`n`tEnter Keyword" find-script -filter $PSGKEYWORD | out-gridview Sleep -Seconds 1 } 2 {#Install script Clear-Host $PSGSCRIPTNAME = Read-Host "`n`tEnter name of script you wish to install" save-Script -Name $PSGSCRIPTNAME -Repository "PSGallery" -Path "C:\PCDiag\PSG" write-host -ForegroundColor yellow "`n`tScript saved" Set-PSRepository -Name "PSG" -SourceLocation C:\PCDiag\PSG -InstallationPolicy Trusted install-script -repository "PSG" -Name $PSGSCRIPTNAME $RUNPSG = "C:\PCDiag\PSG\$PSGSCRIPTNAME.ps1" Write-Host -ForegroundColor yellow "`n`tLaunching script in new window" Sleep -Seconds 1 Start-process powershell.exe -ArgumentList $RUNPSG } } q { $loopSubMenu = $false } default { Write-Host -BackgroundColor Red -ForegroundColor White "You did not enter a valid selection. Please enter a valid selection." sleep -Seconds 3 } } } function loadSubMenu1Option8() { # End of Sub Menu 8 - Powershell Gallery v1.1. } # This section is used for Loading Main Menu Option 9 - Download 3rd Party Utilities v1.1. function mainMenuOption9() { [bool]$loopSubMenu = $true while ($loopSubMenu) { $Host.UI.RawUI.WindowTitle = "PC Diagnostics" Clear-Host Write-Host -BackgroundColor Black -ForegroundColor yellow �`n`PC Diagnostics� Write-Host -ForegroundColor yellow �`n`tDownload 3rd Party Utilities� Write-Host �`t`t1 - Temp File Cleaners� Write-Host �`t`t2 - Malware Tools� Write-Host �`t`t3 - Utilities� Write-Host �`t`t4 - Network Tools� Write-Host -ForegroundColor Yellow �`t`tQ --- Quit And Return To Main Menu`n� $subMenu = Read-Host �`t`tPlease make a selection� switch ($subMenu) { 1 {# Temp File Cleaners <# This section is used for Loading Sub Menu Option 1 - Temp File Cleaners v1.1 #> function loadSublvlMenu() { [bool]$loopSublvlMenu = $true while ($loopSublvlMenu) { Clear-Host Write-Host -BackgroundColor Black -ForegroundColor Yellow �`n`PC Diagnostics� Write-Host -ForegroundColor Yellow �`n`tTemp File Cleaners� Write-Host �`t`t1 - Cleanup� Write-Host �`t`t2 - CCleaner� Write-Host �`t`t3 - New Sub Menu Option 3� Write-Host -ForegroundColor Yellow �`t`tQ --- Quit And Return To Previous Menu`n� $sublvlMenu = Read-Host �`t`tPlease make a selection� # Get user's entry. switch ($sublvlMenu) { 1 {# Cleanup Start-Process "http://stevengould.org/downloads/cleanup/CleanUp452.exe" } 2 {# CCleaner Start-Process "https://www.piriform.com/ccleaner/download/professional" } 3 {# New Menu Option 3 } q { $loopSublvlMenu = $false } default { Write-Host -BackgroundColor Red -ForegroundColor White "You did not enter a valid selection. Please enter a valid selection." sleep -Seconds 3 } } } return } # Start the Sub Menu once loaded: loadSublvlMenu <# End of Sub Menu Option 1 - Temp File Cleaners v1.1 #> } 2 {# Malware Tools <# This section is used for Loading Sub Menu Option 2 - Malware Tools v1.1 #> function loadSublvlMenu() { [bool]$loopSublvlMenu = $true while ($loopSublvlMenu) { Clear-Host Write-Host -BackgroundColor Black -ForegroundColor Yellow �`n`PC Diagnostics� Write-Host -ForegroundColor Yellow �`n`tMalware Tools� Write-Host �`t`t1 - Emsisoft EEK� Write-Host �`t`t2 - Malwarebytes� Write-Host �`t`t3 - Malwarebytes Anti-Rootkit� Write-Host -ForegroundColor Yellow �`t`tQ --- Quit And Return To Previous Menu`n� $sublvlMenu = Read-Host �`t`tPlease make a selection� # Get user's entry. switch ($sublvlMenu) { 1 {# Emsisoft EEK - Malware scanner Start-Process "http://www.emsisoft.com/en/software/eek/download/" } 2 {# Malwarebytes Start-Process "https://www.malwarebytes.com/mwb-download/thankyou/" } 3 {# Malwarebytes Anti-Rootkit Start-Process "https://downloads.malwarebytes.com/file/mbar/" } q { $loopSublvlMenu = $false } default { Write-Host -BackgroundColor Red -ForegroundColor White "You did not enter a valid selection. Please enter a valid selection." sleep -Seconds 3 } } } return } # Start the Sub Menu once loaded: loadSublvlMenu <# End of Sub Menu Option 2 - Malware Tools v1.1 #> } 3 {# Utilities <# This section is used for Loading Sub level Menu Option 3 - Utilities v1.1 #> function loadSublvlMenu() { [bool]$loopSublvlMenu = $true while ($loopSublvlMenu) { Clear-Host Write-Host -BackgroundColor Black -ForegroundColor Yellow �`n`PC Diagnostics� Write-Host -ForegroundColor Yellow �`n`tUtilities� Write-Host �`t`t1 - Microsoft Office Removal Tool� Write-Host �`t`t2 - Revo Uninstaller Pro� Write-Host �`t`t3 - Adobe Flash Player� Write-Host �`t`t4 - Process Explorer� Write-Host �`t`t5 - License Crawler� Write-Host �`t`t6 - KeyFinder� Write-Host -ForegroundColor Yellow �`t`tQ --- Quit And Return To Previous Menu`n� $sublvlMenu = Read-Host �`t`tPlease make a selection� # Get user's entry. switch ($sublvlMenu) { 1 {# Microsoft Office Removal Tool Start-Process "https://aka.ms/diag_officeuninstall" } 2 {# Revo Uninstaller Pro Start-Process "http://www.revouninstaller.com/download-professional-version.php" } 3 {# Adobe Flash Player Start-Process "https://get.adobe.com/flashplayer/otherversions/" } 4 {# Process Explorer Start-Process "https://download.sysinternals.com/files/ProcessExplorer.zip" } 5 {# License Crawler Start-Process "http://www.klinzmann.name/files/licensecrawler.zip" } 6 {# KeyFinder Start-Process "https://www.magicaljellybean.com/downloads/KeyFinderInstaller.exe" } q { $loopSublvlMenu = $false } default { Write-Host -BackgroundColor Red -ForegroundColor White "You did not enter a valid selection. Please enter a valid selection." sleep -Seconds 3 } } } return } # Start the Sub Menu once loaded: loadSublvlMenu <# End of Sub level Menu Option 3 - Utilities v1.1 #> } 4 {# New Menu 4 <# This section is used for Loading Sub level Menu Option 4 - Network Tools v1.1 #> function loadSublvlMenu() { [bool]$loopSublvlMenu = $true while ($loopSublvlMenu) { Clear-Host Write-Host -BackgroundColor Black -ForegroundColor Yellow �`n`PC Diagnostics� Write-Host -ForegroundColor Yellow �`n`tNetwork Tools� Write-Host �`t`t1 - Putty� Write-Host �`t`t2 - Angry IP Scanner� Write-Host �`t`t3 - PortQryUI� Write-Host -ForegroundColor Yellow �`t`tQ --- Quit And Return To Previous Menu`n� $sublvlMenu = Read-Host �`t`tPlease make a selection� # Get user's entry. switch ($sublvlMenu) { 1 {# Putty Start-Process "https://the.earth.li/~sgtatham/putty/latest/w64/putty-64bit-0.68-installer.msi" } 2 {# Angry IP Scanner Start-Process "https://github.com/angryziber/ipscan/releases/download/3.5.1/ipscan-3.5.1-setup.exe" } 3 {# PortQryUI Start-Process "https://www.microsoft.com/en-us/download/confirmation.aspx?id=24009" } q { $loopSublvlMenu = $false } default { Write-Host -BackgroundColor Red -ForegroundColor White "You did not enter a valid selection. Please enter a valid selection." sleep -Seconds 3 } } } return } # Start the Sub Menu once loaded: loadSublvlMenu <# End of Sub level Menu Option 4 - Network Tools v1.1 #> } q { $loopSubMenu = $false } default { Write-Host -BackgroundColor Red -ForegroundColor White "You did not enter a valid selection. Please enter a valid selection." sleep -Seconds 3 } } } } function loadSubMenu1Option9() { # End of Sub Menu 9 - Download 3rd Party Utilities v1.1 . } # This section is used for Loading Main Menu Option 0 - Download Required Powershell Modules v1.1 . function mainMenuOption0() { [bool]$loopSubMenu = $true while ($loopSubMenu) { $Host.UI.RawUI.WindowTitle = "PC Diagnostics" Clear-Host Write-Host -BackgroundColor Black -ForegroundColor yellow �`n`PC Diagnostics� Write-Host -ForegroundColor yellow �`n`tDownload Required Powershell Modules� Write-Host �`t`t1 - Microsoft Online Services Sign-In Assistant� Write-Host �`t`t2 - Windows Azure Active Directory Module PowerShell� Write-Host �`t`t3 - RSAT Tools for Windows 7 with SP1� Write-Host �`t`t4 - Windows Management Framework 3.0� Write-Host �`t`t5 - Windows Management Framework 4.0� Write-Host �`t`t6 - PackageManagement PowerShell Gallery Modules Preview� Write-Host -ForegroundColor Yellow �`t`tQ --- Quit And Return To Main Menu`n� $subMenu = Read-Host �`t`tPlease make a selection� switch ($subMenu) { 1 {# Microsoft Online Services Sign-In Assistant Start-Process "https://www.microsoft.com/en-us/download/details.aspx?id=41950" } 2 {# Windows Azure Active Directory Module for PowerShell Start-Process "https://go.microsoft.com/fwlink/p/?linkid=236297" } 3 {# RSAT Tools for Windows 7 with SP1 Start-Process "https://www.microsoft.com/en-us/download/details.aspx?id=7887" } 4 {# Windows Management Framework 3.0 Start-Process "https://www.microsoft.com/en-us/download/details.aspx?id=34595" } 5 {# Windows Management Framework 4.0 Start-Process "https://www.microsoft.com/en-us/download/details.aspx?id=40855" } 6 {# PackageManagement PowerShell Gallery Modules Preview Start-Process "https://www.microsoft.com/en-us/download/details.aspx?id=51451" } q { $loopSubMenu = $false } default { Write-Host -BackgroundColor Red -ForegroundColor White "You did not enter a valid selection. Please enter a valid selection." sleep -Seconds 3 } } } } function loadSubMenu1Option0() { # End of Sub Menu 0 - New Menu Name v1.1 . } # Start the Main Menu once loaded: loadMainMenu <# ****** End of Main Script ****** #> #TEMPLATES <# # Create Zip Archive sleep -Seconds 1 write-host "Creating archive of collected results on users Desktop" Sleep -seconds 2 # Query users desktop $DESKTOP = [Environment]::GetFolderPath("Desktop") # Create Zip Archive of PCDiag results to users Desktop remove-item -path C:\Temp\PcDiag\Scripts -recurse Add-Type -A System.IO.Compression.FileSystem [IO.Compression.ZipFile]::CreateFromDirectory('\Temp\PCDiag', '\temp\PCDIAG_Results.zip') move-item -path C:\temp\PCDIAG_Results.zip -Destination $DESKTOP Write-host "`nFile - PCDiag_Results.zip - Has been created and placed on the Users Deskop" sleep -Seconds 2 #> # New Menu Template <# # This section is used for Loading Main Menu Option X - Menu Name v1.1 . function mainMenuOptionX() { [bool]$loopSubMenu = $true while ($loopSubMenu) { $Host.UI.RawUI.WindowTitle = "PC Diagnostics" Clear-Host Write-Host -BackgroundColor Black -ForegroundColor yellow �`n`PC Diagnostics� Write-Host -ForegroundColor yellow �`n`tNew Menu Name� Write-Host �`t`t1 - New Menu Option 1� Write-Host �`t`t2 - New Menu Option 2� Write-Host �`t`t3 - New Menu Option 3� Write-Host -ForegroundColor Yellow �`t`tQ --- Quit And Return To Main Menu`n� $subMenu = Read-Host �`t`tPlease make a selection� switch ($subMenu) { 1 {# New Menu Option 1 } 2 {# New Menu Option 2 } 3 {# New Menu Option 3 } q { $loopSubMenu = $false } default { Write-Host -BackgroundColor Red -ForegroundColor White "You did not enter a valid selection. Please enter a valid selection." sleep -Seconds 3 } } } } function loadSubMenu1OptionX() { <# End of Sub Menu X - New Menu Name v1.1. } #> #Write script to file template v1.1 <# #Enter Unique name for $VARIABLES $NAMETITLE = '$Host.UI.RawUI.WindowTitle = "PC Diagnostics - WINDOW NAME"' $VARNAME1 = 'commands and arguments' $VARNAME2 = 'Read-Host -Prompt "Press Enter to exit"' # Prevents new window from auto closing $NAMETITLE | Out-File -filepath c:\PCDiag\Scripts\FILENAME.ps1 $VARNAME1 | Out-File -filepath c:\PCDiag\Scripts\FILENAME.ps1 -append $VARNAME2 | Out-file -filepath c:\PCDiag\Scripts\FILENAME.ps1 -append $VAR = 'c:\PCDiag\Scripts\FILENAME.ps1' Clear-Host write-host -ForegroundColor yellow "`n`nFUNCTION will now Launch in a new window" sleep -Seconds 3 Start-process powershell.exe -ArgumentList "$NAME" sleep -Seconds 2 #> # Sub Menu template <# <# This section is used for Loading Main Sub Menu Option X - Sub Menu Option Name v1.1 # function mainMenuOptionX() { [bool]$loopSubMenu = $true while ($loopSubMenu) { $Host.UI.RawUI.WindowTitle = "PC Diagnostics" Clear-Host Write-Host -BackgroundColor Black -ForegroundColor yellow �`n`PC Diagnostics� Write-Host -ForegroundColor yellow �`n`tMain Sub Menu Option Menu� Write-Host �`t`t1 - Main Sub Menu Option 1� Write-Host �`t`t2 - Main Sub Menu Option 2� Write-Host �`t`t3 - Main Sub Menu Option 3� Write-Host -ForegroundColor Yellow �`t`tQ --- Quit And Return To Main Menu`n� $subMenu = Read-Host �`t`tPlease make a selection� switch ($subMenu) { 1 {# Main Sub Menu Option 1 <# This section is used for Loading Sub Menu Option 1 - Sub Menu Option 1 v1.1 # function loadSublvlMenu() { [bool]$loopSublvlMenu = $true while ($loopSublvlMenu) { Clear-Host Write-Host -BackgroundColor Black -ForegroundColor Yellow �`n`PC Diagnostics� Write-Host -ForegroundColor Yellow �`n`tMain Sub Menu Option 1� Write-Host �`t`t1 - New Sub lvl Menu Option 1� Write-Host �`t`t2 - New Sub lvl Menu Option 2� Write-Host �`t`t3 - New Sub lvl Menu Option 3� Write-Host -ForegroundColor Yellow �`t`tQ --- Quit And Return To Previous Menu`n� $sublvlMenu = Read-Host �`t`tPlease make a selection� # Get user's entry. switch ($sublvlMenu) { 1 {# New Sub lvl Menu Option 1 } 2 {# New Sub lvl Menu Option 2 } 3 {# New Sub lvl Menu Option 3 } q { $loopSublvlMenu = $false } default { Write-Host -BackgroundColor Red -ForegroundColor White "You did not enter a valid selection. Please enter a valid selection." sleep -Seconds 3 } } } return } # Start the Sub Menu once loaded: loadSublvlMenu <# End of Sub lvl Menu Option 1 - Sub lvl Menu Option 1 v1.1 # } 2 {# Main Sub Menu Option 2 <# This section is used for Loading Main Sub Menu Option 2 - Sub Menu Option 2 v1.1 # <# Copy Main Sub Menu Option 1 code # { 1 {# New Sub lvl Menu Option 1 } 2 {# New Sub lvl Menu Option 2 } 3 {# New Sub lvl Menu Option 3 } q { $loopSublvlMenu = $false } default { Write-Host -BackgroundColor Red -ForegroundColor White "You did not enter a valid selection. Please enter a valid selection." sleep -Seconds 3 } } } return } # Start the Sub Menu once loaded: loadSublvlMenu <# End of Main Sub Menu Option 2 - Sub Menu Option 2 v1.1 # } 3 {# Main Sub Menu Option 3 <# This section is used for Loading Main Sub Menu Option 3 - Sub Menu Option 3 v1.1 # <# Copy Main Sub Menu Option 1 code # { 1 {# New Sub lvl Menu Option 1 } 2 {# New Sub lvl Menu Option 2 } 3 {# New Sub lvl Menu Option 3 } q { $loopSublvlMenu = $false } default { Write-Host -BackgroundColor Red -ForegroundColor White "You did not enter a valid selection. Please enter a valid selection." sleep -Seconds 3 } } } return } # Start the Sub Menu once loaded: loadSublvlMenu <# End of Sub level Menu Option 3 - Sub Menu Option 3 v1.1 # } q { $loopSubMenu = $false } default { Write-Host -BackgroundColor Red -ForegroundColor White "You did not enter a valid selection. Please enter a valid selection." sleep -Seconds 3 } } } } function loadSubMenu1OptionX() { <# End of Main Sub Menu Option X - Sub Menu Option Name v1.1 # } #>