# Software Installation Script (Modified)

# Define installation paths and download URLs (adjust as needed)
$ChromeInstaller = "$env:TEMP\ChromeSetup.exe"
$ChromeURL = "https://dl.google.com/tag/s/appguid%3D%7B8A69D345-D564-463C-AFF1-A69D9E530F96%7D%26iid%3D%7B76F97539-C462-43E3-8E61-E373F60D80E4%7D%26lang%3Den%26browser%3D4%26usagestats%3D1%26apptype%3Dstandalone/update2/installers/ChromeSetup.exe"

$NotepadPlusPlusInstaller = "$env:TEMP\npp.exe"
$NotepadPlusPlusURL = "https://github.com/notepad-plus-plus/notepad-plus-plus/releases/latest/download/npp.latest.installer.x64.exe"

$GroupWiseInstaller = "$env:TEMP\gw24.exe" # Replace with actual URL/path
$GroupWiseURL = "https://file.mkau.au/u/gw24.4_client_win_multi.exe"

$BitviseInstaller = "$env:TEMP\BvSshClient-Inst.exe"
$BitviseURL = "https://dl.bitvise.com/BvSshClient-Inst.exe"

$PuttyInstaller = "$env:TEMP\putty-64bit.msi"
$PuttyURL = "https://the.earth.li/~sgtatham/putty/latest/w64/putty-64bit.msi"

$RocketChatInstaller = "$env:TEMP\Rocket.exe"
$RocketChatURL = "https://github.com/RocketChat/Rocket.Chat.Electron/releases/latest/download/rocketchat-setup-x64.exe"

$PythonInstaller = "$env:TEMP\python-3.13.0-amd64.exe" #Adjust version number as needed.
$PythonURL = "https://www.python.org/ftp/python/3.13.0/python-3.13.0-amd64.exe" #Adjust version number as needed.

# Client for Open Enterprise Server and ESET Antivirus (Files to be provided)
$OESClientInstaller = "https://file.mkau.au/u/Client%20for%20Open%20Enterprise%20Server%2024.1.exe" # Replace with actual path
$ESETInstaller = "https://file.mkau.au/u/eset.exe" # Replace with actual path

$7zipInstaller = "$env:TEMP\7z2409-x64.exe" #Adjust version number as needed.
$7zipURL = "https://file.mkau.au/u/7z2409-x64.exe" #Adjust version number as needed.

# Function to download and install software
function Install-Software {
    param (
        [string]$InstallerPath,
        [string]$DownloadURL,
        [string]$InstallArguments = "/silent /norestart" #Default silent install
    )

    try {
        if ($DownloadURL){ #checks if a URL is provided, if not, it assumes its a local file.
           Write-Host "Downloading $InstallerPath..."
           Invoke-WebRequest -Uri $DownloadURL -OutFile $InstallerPath
        }

        Write-Host "Installing $InstallerPath..."
        Start-Process -FilePath $InstallerPath -ArgumentList $InstallArguments -Wait -NoNewWindow

        Write-Host "$InstallerPath installed successfully."
    }
    catch {
        Write-Error "Error installing $InstallerPath: $($_.Exception.Message)"
    }
}

# Install Chrome
Install-Software -InstallerPath $ChromeInstaller -DownloadURL $ChromeURL -InstallArguments "/silent /install"

# Install Notepad++
Install-Software -InstallerPath $NotepadPlusPlusInstaller -DownloadURL $NotepadPlusPlusURL "/S" # Notepad++ uses "/S" for silent install

# Install GroupWise (Requires manual URL/path)
Install-Software -InstallerPath $GroupWiseInstaller -DownloadURL $GroupWiseURL

# Install Bitvise SSH Client
Install-Software -InstallerPath $BitviseInstaller -DownloadURL $BitviseURL "/verysilent"

# Install Putty
Install-Software -InstallerPath $PuttyInstaller -DownloadURL $PuttyURL "/quiet"

#Install RocketChat
Install-Software -InstallerPath $RocketChatInstaller -DownloadURL $RocketChatURL "/S"

# Install Python 3.13
Install-Software -InstallerPath $PythonInstaller -DownloadURL $PythonURL "/quiet InstallAllUsers=1 Include_pip=1 PrependPath=1"

# Install Client for Open Enterprise Server
Install-Software -InstallerPath $OESClientInstaller -DownloadURL $null "/quiet" #assuming a quiet install

# Install ESET Antivirus
Install-Software -InstallerPath $ESETInstaller -DownloadURL $null "/silent" #assuming a silent install

# Install 7zip
Install-Software -InstallerPath $7zipInstaller -DownloadURL $7zipURL "/quiet"

Write-Host "Software installation complete."