Tag: #Utility

  • Windows Security Features Check PowerShell Script

    This PowerShell script provides a quick and colorful overview of key Windows 11 security features, including Microsoft Defender, Firewall, Secure Boot, BitLocker, VBS, Credential Guard, and TPM status. It uses error handling to ensure reliability and presents results in an easy-to-read format, highlighting whether each feature is enabled or disabled.

    Click to view script…
    # Quick Windows 11 Security Features Check
    
    # Check if the script is running with administrator privileges
    if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
        Write-Warning "This script should be run as Administrator for full functionality."
    }
    
    # Microsoft Defender Status
    Write-Host "`nMicrosoft Defender Status:" -ForegroundColor Cyan
    $defenderStatus = Get-MpComputerStatus
    Write-Host "Antivirus Enabled: " -NoNewline
    if ($defenderStatus.AntivirusEnabled) { Write-Host "Yes" -ForegroundColor Green } else { Write-Host "No" -ForegroundColor Red }
    Write-Host "Real-Time Protection: " -NoNewline
    if ($defenderStatus.RealTimeProtectionEnabled) { Write-Host "Yes" -ForegroundColor Green } else { Write-Host "No" -ForegroundColor Red }
    Write-Host "Tamper Protected: " -NoNewline
    if ($defenderStatus.IsTamperProtected) { Write-Host "Yes" -ForegroundColor Green } else { Write-Host "No" -ForegroundColor Red }
    
    # Firewall Status
    Write-Host "`nFirewall Status:" -ForegroundColor Cyan
    $firewallStatus = Get-NetFirewallProfile
    foreach ($profile in $firewallStatus) {
        Write-Host "$($profile.Name) Profile: " -NoNewline
        if ($profile.Enabled) { Write-Host "Enabled" -ForegroundColor Green } else { Write-Host "Disabled" -ForegroundColor Red }
    }
    
    # Secure Boot Status
    Write-Host "`nSecure Boot:" -ForegroundColor Cyan
    try {
        $secureBoot = Confirm-SecureBootUEFI
        Write-Host "Status: " -NoNewline
        if ($secureBoot) { Write-Host "Enabled" -ForegroundColor Green } else { Write-Host "Disabled" -ForegroundColor Red }
    } catch {
        Write-Host "Status: Not supported or error occurred" -ForegroundColor Yellow
    }
    
    # BitLocker Status
    Write-Host "`nBitLocker Status:" -ForegroundColor Cyan
    $bitLockerStatus = Get-BitLockerVolume
    foreach ($volume in $bitLockerStatus) {
        Write-Host "$($volume.MountPoint) Protection: " -NoNewline
        if ($volume.ProtectionStatus -eq "On") { Write-Host "On" -ForegroundColor Green } else { Write-Host "Off" -ForegroundColor Red }
    }
    
    # VBS and Credential Guard
    Write-Host "`nVBS and Credential Guard:" -ForegroundColor Cyan
    try {
        $deviceGuard = Get-CimInstance -ClassName Win32_DeviceGuard -ErrorAction Stop
        $vbsStatus = if ($deviceGuard.VirtualizationBasedSecurityStatus -eq 2) { "Enabled" } else { "Disabled" }
        $credGuard = if ($deviceGuard.SecurityServicesRunning -contains 1) { "Enabled" } else { "Disabled" }
        Write-Host "VBS: " -NoNewline
        if ($vbsStatus -eq "Enabled") { Write-Host "Enabled" -ForegroundColor Green } else { Write-Host "Disabled" -ForegroundColor Red }
        Write-Host "Credential Guard: " -NoNewline
        if ($credGuard -eq "Enabled") { Write-Host "Enabled" -ForegroundColor Green } else { Write-Host "Disabled" -ForegroundColor Red }
    } catch {
        Write-Host "VBS and Credential Guard status not available on this system." -ForegroundColor Yellow
    }
    
    # TPM Status
    Write-Host "`nTPM Status:" -ForegroundColor Cyan
    $tpmStatus = Get-Tpm
    Write-Host "TPM Present: " -NoNewline
    if ($tpmStatus.TpmPresent) { Write-Host "Yes" -ForegroundColor Green } else { Write-Host "No" -ForegroundColor Red }
    Write-Host "TPM Ready: " -NoNewline
    if ($tpmStatus.TpmReady) { Write-Host "Yes" -ForegroundColor Green } else { Write-Host "No" -ForegroundColor Red }
    
    Write-Host "`nSecurity Features Check Complete" -ForegroundColor Cyan
  • Identify Pending Windows Updates PowerShell Script

    This PowerShell script utilizes the Windows Update Agent API to scan for available updates that are not yet installed, displaying a detailed list of pending updates including their titles, KB numbers, download status, and descriptions. It provides a quick and reliable way to check the update status of a Windows system without requiring manual intervention through the Settings app.

    Click to view script…
    # PowerShell script to check for Windows updates and list pending updates
    
    try {
        Write-Output "Checking for updates..."
        
        # Create a new update session
        $session = New-Object -ComObject Microsoft.Update.Session
        
        # Create an update searcher
        $searcher = $session.CreateUpdateSearcher()
        
        # Set the search criteria to find updates that are not installed and not hidden
        $criteria = "IsInstalled=0 and IsHidden=0"
        
        # Perform the search
        $result = $searcher.Search($criteria)
        
        # Check if the search was successful (ResultCode 2 means Succeeded)
        if ($result.ResultCode -eq 2) {
            $updates = $result.Updates
            if ($updates.Count -gt 0) {
                Write-Output "Found $($updates.Count) pending updates:"
                $counter = 1
                foreach ($update in $updates) {
                    # Get the KB article ID if available
                    $kb = if ($update.KBArticleIDs.Count -gt 0) { $update.KBArticleIDs[0] } else { "N/A" }
                    # Check if the update is downloaded
                    $status = if ($update.IsDownloaded) { "Downloaded" } else { "Not Downloaded" }
                    Write-Output "$counter. Title: $($update.Title) (KB$kb) - $status"
                    Write-Output "   Description: $($update.Description)"
                    Write-Output ""
                    $counter++
                }
            } else {
                Write-Output "No pending updates found."
            }
        } else {
            Write-Output "Update search failed with result code $($result.ResultCode)"
        }
    } catch {
        Write-Output "An error occurred: $($_.Exception.Message)"
    }
  • Retrieve Detailed System Specifications PowerShell Script

    This PowerShell script collects and displays comprehensive system specifications for a Windows machine, including details about the operating system, processor, memory, disk drives, graphics, network adapters, and motherboard/BIOS. It organizes the information into a clear, readable format, making it ideal for system diagnostics, inventory tracking, or personal reference.

    Click to view script…
    # Get OS Information
    $os = Get-WmiObject -Class Win32_OperatingSystem
    $installDate = [System.Management.ManagementDateTimeConverter]::ToDateTime($os.InstallDate)
    Write-Output "Operating System Information:"
    Write-Output "OS Name: $($os.Caption)"
    Write-Output "Version: $($os.Version)"
    Write-Output "Build Number: $($os.BuildNumber)"
    Write-Output "Installation Date: $installDate"
    Write-Output ""
    
    # Get Processor Information
    $processors = Get-WmiObject -Class Win32_Processor
    $totalCores = ($processors | Measure-Object -Property NumberOfCores -Sum).Sum
    $totalThreads = ($processors | Measure-Object -Property NumberOfLogicalProcessors -Sum).Sum
    $processorName = $processors[0].Name
    $maxClockSpeed = $processors[0].MaxClockSpeed
    Write-Output "Processor Information:"
    Write-Output "Processor: $processorName"
    Write-Output "Total Cores: $totalCores"
    Write-Output "Total Threads: $totalThreads"
    Write-Output "Max Clock Speed: $maxClockSpeed MHz"
    Write-Output ""
    
    # Get Memory Information
    $memory = Get-WmiObject -Class Win32_PhysicalMemory
    $totalRAM = [math]::Round(($memory | Measure-Object -Property Capacity -Sum).Sum / 1GB, 2)
    Write-Output "Memory Information:"
    Write-Output "Total RAM: $totalRAM GB"
    Write-Output ""
    
    # Get Disk Information
    $disks = Get-WmiObject -Class Win32_DiskDrive
    Write-Output "Disk Information:"
    foreach ($disk in $disks) {
        $sizeGB = [math]::Round($disk.Size / 1GB, 2)
        Write-Output "Disk Model: $($disk.Model)"
        Write-Output "Size: $sizeGB GB"
        Write-Output ""
    }
    
    # Get Graphics Information
    $gpus = Get-WmiObject -Class Win32_VideoController
    Write-Output "Graphics Information:"
    foreach ($gpu in $gpus) {
        Write-Output "Graphics Card: $($gpu.Name)"
        Write-Output "Resolution: $($gpu.VideoModeDescription)"
        Write-Output ""
    }
    
    # Get Network Information
    $adapters = Get-NetAdapter | Where-Object {$_.Status -eq 'Up'}
    Write-Output "Network Information:"
    foreach ($adapter in $adapters) {
        Write-Output "Adapter Name: $($adapter.Name)"
        Write-Output "MAC Address: $($adapter.MacAddress)"
        $ipAddresses = Get-NetIPAddress -InterfaceIndex $adapter.InterfaceIndex | Where-Object {$_.AddressFamily -eq 'IPv4'}
        Write-Output "IP Addresses:"
        foreach ($ip in $ipAddresses) {
            Write-Output "  $($ip.IPAddress)"
        }
        Write-Output ""
    }
    
    # Get Motherboard and BIOS Information
    $motherboard = Get-WmiObject -Class Win32_BaseBoard
    $bios = Get-WmiObject -Class Win32_BIOS
    $biosDate = [System.Management.ManagementDateTimeConverter]::ToDateTime($bios.ReleaseDate)
    Write-Output "Motherboard and BIOS Information:"
    Write-Output "Motherboard Manufacturer: $($motherboard.Manufacturer)"
    Write-Output "Motherboard Model: $($motherboard.Product)"
    Write-Output "BIOS Manufacturer: $($bios.Manufacturer)"
    Write-Output "BIOS Version: $($bios.Version)"
    Write-Output "BIOS Release Date: $biosDate"
  • List Windows Version and Updates PowerShell Script

    This PowerShell script retrieves and displays the current Windows operating system name and version, including the major, minor, build, and revision numbers. It also lists all installed updates, sorted by installation date, with details such as the hotfix ID, description, and when each update was applied.

    Click to view script…
    # Get OS name
    $os = Get-CimInstance -ClassName Win32_OperatingSystem
    $osName = $os.Caption
    
    # Get OS version
    $osVersion = [System.Environment]::OSVersion.Version
    
    # Display OS name and version
    Write-Output "Operating System: $osName"
    Write-Output "Version: $($osVersion.Major).$($osVersion.Minor).$($osVersion.Build).$($osVersion.Revision)"
    
    # Get and display installed updates
    Write-Output "Installed Updates:"
    Get-HotFix | Sort-Object InstalledOn | Format-Table HotFixID, Description, InstalledOn
  • Interactive Sequential Folder Creator PowerShell Script

    This PowerShell script allows users to select a target directory either by entering a path directly or by navigating through subdirectories with a numbered menu. Once a directory is chosen, the script creates a series of sequentially numbered folders using a base name provided by the user.

    Click to view script…
    # Function: Recursively select a folder by listing subdirectories
    function Select-Folder($startingPath) {
        $currentPath = $startingPath
        while ($true) {
            Write-Host "`nCurrent Directory: $currentPath" -ForegroundColor Cyan
    
            # Get subdirectories (if any)
            $subDirs = Get-ChildItem -Path $currentPath -Directory -ErrorAction SilentlyContinue
    
            if (!$subDirs -or $subDirs.Count -eq 0) {
                Write-Host "No subdirectories found in $currentPath. Using this folder."
                break
            }
    
            # List options: 0 to select current folder, then list each subfolder with a number
            Write-Host "0: [Select this directory]"
            $index = 1
            foreach ($dir in $subDirs) {
                Write-Host ("{0}: {1}" -f $index, $dir.Name)
                $index++
            }
    
            $choice = Read-Host "Enter the number to navigate into a folder, or 0 to select the current directory"
    
            if (-not [int]::TryParse($choice, [ref]$null)) {
                Write-Host "Invalid input. Please enter a number."
                continue
            }
    
            $choice = [int]$choice
    
            if ($choice -eq 0) {
                break
            }
            elseif ($choice -ge 1 -and $choice -le $subDirs.Count) {
                $currentPath = $subDirs[$choice - 1].FullName
            }
            else {
                Write-Host "Invalid selection. Please try again."
            }
        }
        return $currentPath
    }
    
    # Prompt the user to choose the directory selection method
    Write-Host "Select target directory method:" -ForegroundColor Green
    Write-Host "1: Type the full directory path"
    Write-Host "2: Navigate directories using a numbered list"
    $method = Read-Host "Enter 1 or 2"
    
    if ($method -eq "1") {
        $targetDirectory = Read-Host "Enter the target directory path"
        if (-not (Test-Path $targetDirectory)) {
            Write-Host "Directory '$targetDirectory' does not exist. Exiting." -ForegroundColor Red
            exit
        }
    }
    elseif ($method -eq "2") {
        # Optionally allow the user to set a starting directory; default is C:\
        $startingPath = Read-Host "Enter starting directory path (press Enter for default C:\)"
        if ([string]::IsNullOrWhiteSpace($startingPath)) {
            $startingPath = "C:\"
        }
        if (-not (Test-Path $startingPath)) {
            Write-Host "The starting directory '$startingPath' does not exist. Exiting." -ForegroundColor Red
            exit
        }
        $targetDirectory = Select-Folder $startingPath
        Write-Host "Selected Directory: $targetDirectory" -ForegroundColor Green
    }
    else {
        Write-Host "Invalid selection. Exiting." -ForegroundColor Red
        exit
    }
    
    # Prompt user for the base folder name
    $baseName = Read-Host "Enter the base folder name for the folders to be created"
    
    # Prompt user for the number of folders to create
    $numFoldersInput = Read-Host "Enter the number of folders to create"
    if (-not [int]::TryParse($numFoldersInput, [ref]$null)) {
        Write-Host "The number of folders must be a valid integer. Exiting." -ForegroundColor Red
        exit
    }
    $numFolders = [int]$numFoldersInput
    
    # Create folders sequentially
    for ($i = 1; $i -le $numFolders; $i++) {
        # Construct folder name: "BaseName 1", "BaseName 2", etc.
        $folderName = "{0} {1}" -f $baseName, $i
        $folderPath = Join-Path $targetDirectory $folderName
    
        if (-not (Test-Path $folderPath)) {
            New-Item -Path $folderPath -ItemType Directory | Out-Null
            Write-Host "Created folder: $folderPath" -ForegroundColor Yellow
        }
        else {
            Write-Host "Folder already exists: $folderPath" -ForegroundColor DarkYellow
        }
    }
  • Installed Applications Info PowerShell Script

    This PowerShell script scans the Windows registry for installed applications, retrieving key details such as application name, version number, publisher, and installation date. It then displays the information in a neatly formatted table, making it easy to audit and manage software installations on your system.

    Click to view script…
    # Define registry paths for 64-bit and 32-bit applications
    $registryPaths = @(
        "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*",
        "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
    )
    
    # Retrieve applications from the registry
    $installedApps = foreach ($path in $registryPaths) {
        Get-ItemProperty -Path $path -ErrorAction SilentlyContinue |
            Where-Object { $_.DisplayName -and $_.DisplayVersion }
    }
    
    # Display the results in a formatted table
    $installedApps |
        Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |
        Sort-Object DisplayName |
        Format-Table -AutoSize
  • Smart Finder Tabs Launcher for macOS AppleScript

    This AppleScript streamlines your Finder workspace by checking for an existing Finder window and reusing it to open specified folders as individual tabs, thereby avoiding duplicate windows or tabs. Customize the folders by editing the definitions at the top of the script.

    The folder paths are defined near the beginning of the script. For example, you can customize the following lines to change which folders open:

    set docsFolder to (path to documents folder)
    set desktopFolder to (path to desktop folder)
    set downloadsFolder to (path to downloads folder)


    Simply modify these variables to point to your desired folder paths.

    Click to view script…
    -- Title: Finder Tabs Organizer
    -- Description:
    -- This AppleScript opens designated folders as tabs in Finder
    -- Customize the folders to open by modifying the folder definitions below.
    
    -- Handler to open a new tab for a given folder
    on openNewTabWithFolder(theFolder)
        tell application "System Events"
            keystroke "t" using {command down} -- simulate Command+T to open a new tab
        end tell
        delay 0.5
        tell application "Finder"
            set target of front Finder window to theFolder
        end tell
    end openNewTabWithFolder
    
    -- Define the folders to open
    set docsFolder to (path to documents folder)
    set desktopFolder to (path to desktop folder)
    set downloadsFolder to (path to downloads folder)
    
    tell application "Finder"
        activate
        if (count of Finder windows) > 0 then
            -- Use the existing Finder window and set its target to Documents
            set target of front Finder window to docsFolder
        else
            -- No window exists, so open a new window for Documents
            open docsFolder
        end if
    end tell
    
    delay 0.5
    
    -- Open additional tabs for the other folders.
    openNewTabWithFolder(desktopFolder)
    openNewTabWithFolder(downloadsFolder)

  • macOS User Login and Uptime Report Bash Script

    This script provides system administrators with a clear overview of the system’s current uptime and detailed last login information for human user accounts (UID ≥ 500). It displays key details such as the terminal, login date, login time, and session status for each account.

    Click to view script…
    #!/bin/bash
    # Title: Detailed macOS User Last Login Checker with System Uptime
    # Description:
    # This script lists human user accounts (UID ≥ 500) on macOS and displays detailed information about their last login session.
    # It also shows the current system uptime at the top.
    #
    # The output includes:
    #   - System Uptime: How long the machine has been running since the last boot.
    #   - Username     : The account name.
    #   - Terminal     : The terminal device used during login.
    #   - Login Date   : The date of the login (Day Month Date).
    #   - Login Time   : The time when the login occurred.
    #   - Login Status : Indicates if the session is still active or has ended.
    #
    # Note: "Never logged in" is shown if no login record exists.
    #
    # Retrieve and display system uptime
    systemUptime=$(uptime)
    echo "System Uptime: $systemUptime"
    echo ""
    
    # Print header for the login details
    echo "Username | Terminal | Login Date       | Login Time | Login Status"
    echo "---------------------------------------------------------------------"
    
    # List users with their UniqueIDs and process each one.
    dscl . -list /Users UniqueID | while read username uid; do
        if [ "$uid" -ge 500 ]; then
            # Retrieve the most recent login record for the user
            loginInfo=$(last -1 "$username" | head -n 1)
            
            # Check if there is a valid login record
            if echo "$loginInfo" | grep -q "wtmp begins"; then
                echo "$username |    -     |       -        |     -    | Never logged in"
            else
                # Parse the login record:
                #   Field 1: Username (redundant here)
                #   Field 2: Terminal (e.g., ttys000)
                #   Fields 3-5: Login Date (e.g., "Mon Feb 17")
                #   Field 6: Login Time (e.g., "05:44")
                #   Fields 7+: Login Status (e.g., "still logged in" or the session end time)
                terminal=$(echo "$loginInfo" | awk '{print $2}')
                login_date=$(echo "$loginInfo" | awk '{print $3, $4, $5}')
                login_time=$(echo "$loginInfo" | awk '{print $6}')
                login_status=$(echo "$loginInfo" | cut -d' ' -f7-)
                
                # Output the parsed details in a table-like format
                printf "%-8s | %-8s | %-16s | %-10s | %s\n" "$username" "$terminal" "$login_date" "$login_time" "$login_status"
            fi
        fi
    done
    
    # Legend:
    #   System Uptime - How long the system has been running since the last boot.
    #   Username      - The account name.
    #   Terminal      - The terminal device used during login.
    #   Login Date    - The date of the login (Day Month Date).
    #   Login Time    - The time of the login.
    #   Login Status  - The current status of the login session.
  • Enhanced macOS User Account Details Bash Script

    This Bash script retrieves and displays detailed information for all human user accounts (UID ≥ 500) on macOS, including the username, UID, admin privileges, full name, home directory, and default shell. It provides a clear and organized summary that is useful for system administrators to review and manage user configurations.

    Click to view script…
    #!/bin/bash
    # This script lists user accounts (UID >= 500) and shows additional details:
    # Username, UID, Admin Privileges (true/false), Full Name, Home Directory, and Shell
    
    # Print header for clarity
    echo "Username : UID : Has Admin Privileges : Full Name : Home Directory : Shell"
    
    # List all users with their UniqueID and process each line
    dscl . -list /Users UniqueID | while read username uid; do
        # Only process accounts with UID >= 500 (typically non-system, human user accounts)
        if [ "$uid" -ge 500 ]; then
            # Check if the user belongs to the 'admin' group
            if id -Gn "$username" 2>/dev/null | grep -qw "admin"; then
                adminFlag="true"
            else
                adminFlag="false"
            fi
    
            # Get the user's full name (if set). The command outputs a line like "RealName: John Doe"
            fullName=$(dscl . -read /Users/"$username" RealName 2>/dev/null | sed 's/RealName: //')
            
            # Get the user's home directory
            homeDir=$(dscl . -read /Users/"$username" NFSHomeDirectory 2>/dev/null | sed 's/NFSHomeDirectory: //')
            
            # Get the user's default shell
            shell=$(dscl . -read /Users/"$username" UserShell 2>/dev/null | sed 's/UserShell: //')
            
            # Output the collected information in a clear, colon-separated format
            echo "$username : $uid : $adminFlag : $fullName : $homeDir : $shell"
        fi
    done
  • Scheduled URL Launcher AppleScript

    This AppleScript prompts the user to input multiple URLs and offers a choice to open them immediately or after a countdown timer. For immediate launches, it confirms the URLs before opening, while for countdown mode it notifies the user that the countdown has started and then provides a final confirmation after the URLs have been opened.

    Click to view script…
    -- Create a large default text field by including multiple line breaks
    set multiLineDefault to return & return & return & return
    
    -- Prompt the user for a list of URLs (one URL per line)
    set urlInput to text returned of (display dialog "Enter list of URLs (one per line):" default answer multiLineDefault)
    
    -- Split the input into a list of lines
    set urlList to paragraphs of urlInput
    
    -- Ask the user if they want to open the URLs now or after a countdown
    set schedulingOption to button returned of (display dialog "Choose when to open the URLs:" buttons {"Now", "Countdown"} default button "Now")
    
    if schedulingOption is "Now" then
    	-- Build a confirmation message listing the URLs to be opened immediately
    	set confirmDialogText to "The following URLs will be opened now:" & return & return
    	repeat with aURL in urlList
    		set trimmedURL to trimWhitespace(aURL)
    		if trimmedURL is not "" then
    			-- Prepend protocol if missing
    			if (trimmedURL does not start with "http://") and (trimmedURL does not start with "https://") then
    				set trimmedURL to "https://" & trimmedURL
    			end if
    			set confirmDialogText to confirmDialogText & trimmedURL & return
    		end if
    	end repeat
    	
    	-- Show confirmation dialog before launching
    	set confirmResponse to button returned of (display dialog confirmDialogText buttons {"Cancel", "Open Now"} default button "Open Now")
    	if confirmResponse is "Cancel" then return
    	
    	-- Open URLs immediately
    	repeat with aURL in urlList
    		set trimmedURL to trimWhitespace(aURL)
    		if trimmedURL is not "" then
    			if (trimmedURL does not start with "http://") and (trimmedURL does not start with "https://") then
    				set trimmedURL to "https://" & trimmedURL
    			end if
    			open location trimmedURL
    		end if
    	end repeat
    	
    else if schedulingOption is "Countdown" then
    	-- Prompt for countdown seconds
    	set countdownInput to text returned of (display dialog "Enter countdown time in seconds:" default answer "10")
    	try
    		set countdownSeconds to countdownInput as integer
    	on error
    		display dialog "Invalid number. Exiting." buttons {"OK"} default button "OK"
    		return
    	end try
    	
    	-- Notify the user that the countdown is starting
    	display dialog "Countdown started for " & countdownSeconds & " seconds. The URLs will open automatically afterwards." buttons {"OK"} default button "OK"
    	
    	-- Delay for the specified number of seconds
    	delay countdownSeconds
    	
    	-- Open URLs after the delay
    	repeat with aURL in urlList
    		set trimmedURL to trimWhitespace(aURL)
    		if trimmedURL is not "" then
    			if (trimmedURL does not start with "http://") and (trimmedURL does not start with "https://") then
    				set trimmedURL to "https://" & trimmedURL
    			end if
    			open location trimmedURL
    		end if
    	end repeat
    	
    	-- Build a final confirmation message listing the URLs that were opened
    	set finalConfirmDialogText to "The following URLs have been opened:" & return & return
    	repeat with aURL in urlList
    		set trimmedURL to trimWhitespace(aURL)
    		if trimmedURL is not "" then
    			if (trimmedURL does not start with "http://") and (trimmedURL does not start with "https://") then
    				set trimmedURL to "https://" & trimmedURL
    			end if
    			set finalConfirmDialogText to finalConfirmDialogText & trimmedURL & return
    		end if
    	end repeat
    	
    	-- Show the final confirmation dialog
    	display dialog finalConfirmDialogText buttons {"OK"} default button "OK"
    end if
    
    --------------------------------------------------------------------------------
    -- Helper Handler: trimWhitespace
    -- Removes leading and trailing whitespace from a string
    --------------------------------------------------------------------------------
    on trimWhitespace(theText)
    	set AppleScript's text item delimiters to {" ", tab, return, linefeed}
    	set textItems to text items of theText
    	set AppleScript's text item delimiters to space
    	set trimmed to textItems as text
    	set AppleScript's text item delimiters to ""
    	return trimmed
    end trimWhitespace