Last active
June 9, 2024 21:12
-
-
Save PaulGG-Code/dc236b265f70918522f3f27d75522811 to your computer and use it in GitHub Desktop.
Automatically installing the needed tools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Ensure the script execution policy allows running scripts | |
| Set-ExecutionPolicy RemoteSigned -Scope Process -Force | |
| # Check for administrative privileges | |
| if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) | |
| { | |
| # Relaunch the script with elevated privileges | |
| $arguments = "-NoProfile -ExecutionPolicy Bypass -File ""$PSCommandPath""" | |
| Start-Process PowerShell -Verb RunAs -ArgumentList $arguments | |
| exit | |
| } | |
| # Define the URLs for the installers | |
| $installers = @{ | |
| "Nifty Project Management" = "https://nifty-apps.s3.amazonaws.com/Nifty.exe" | |
| "OpenVPN Client" = "https://swupdate.openvpn.org/community/releases/OpenVPN-2.6.10-I003-amd64.msi" | |
| "KeePass" = "https://sourceforge.net/projects/keepass/files/KeePass%202.x/2.56/KeePass-2.56-Setup.exe" | |
| "Slack" = "https://downloads.slack-edge.com/desktop-releases/windows/x64/4.38.127/SlackSetup.exe" | |
| "Chrome" = "https://dl.google.com/chrome/install/latest/chrome_installer.exe" | |
| } | |
| # Function to download and install applications | |
| function Install-Application { | |
| param ( | |
| [string]$Name, | |
| [string]$Url | |
| ) | |
| if ($Name -eq "KeePass") { | |
| $installerPath = "$env:USERPROFILE\Downloads\KeePass2-Latest.exe" | |
| Write-Output "Downloading KeePass..." | |
| Invoke-WebRequest -UserAgent "Wget" -Uri $Url -OutFile $installerPath | |
| } else { | |
| $installerPath = "$env:TEMP\$Name.exe" | |
| Write-Output "Downloading $Name..." | |
| Invoke-WebRequest -Uri $Url -OutFile $installerPath | |
| } | |
| Write-Output "Installing $Name..." | |
| if ($Name -eq "OpenVPN Client") { | |
| Start-Process msiexec.exe -ArgumentList "/i", $installerPath, "/quiet", "/norestart" -Wait | |
| } else { | |
| Start-Process -FilePath $installerPath -ArgumentList "/quiet", "/norestart" -Wait | |
| } | |
| # Cleanup | |
| Remove-Item -Path $installerPath | |
| Write-Output "$Name installation completed." | |
| } | |
| # Install each application | |
| foreach ($app in $installers.GetEnumerator()) { | |
| Install-Application -Name $app.Key -Url $app.Value | |
| } | |
| Write-Output "All applications have been installed." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Check for administrative privileges | |
| if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) | |
| { | |
| # Relaunch the script with elevated privileges | |
| $arguments = "-NoProfile -ExecutionPolicy Bypass -File ""$PSCommandPath""" | |
| Start-Process PowerShell -Verb RunAs -ArgumentList $arguments | |
| exit | |
| } | |
| # Define the URLs for the installers | |
| $installers = @{ | |
| "Nifty Project Management" = "https://nifty-apps.s3.amazonaws.com/Nifty.exe" | |
| "OpenVPN Client" = "https://swupdate.openvpn.org/community/releases/OpenVPN-2.6.10-I003-amd64.msi" | |
| "KeePass" = "https://sourceforge.net/projects/keepass/files/KeePass%202.x/2.56/KeePass-2.56-Setup.exe" | |
| "Slack" = "https://downloads.slack-edge.com/desktop-releases/windows/x64/4.38.127/SlackSetup.exe" | |
| "Chrome" = "https://dl.google.com/chrome/install/latest/chrome_installer.exe" | |
| } | |
| # Function to download and install applications | |
| function Install-Application { | |
| param ( | |
| [string]$Name, | |
| [string]$Url | |
| ) | |
| $installerPath = "$env:TEMP\$Name.exe" | |
| Write-Output "Downloading $Name..." | |
| Invoke-WebRequest -Uri $Url -OutFile $installerPath | |
| Write-Output "Installing $Name..." | |
| if ($Name -eq "OpenVPN Client") { | |
| Start-Process msiexec.exe -ArgumentList "/i", $installerPath, "/quiet", "/norestart" -Wait | |
| } else { | |
| Start-Process -FilePath $installerPath -ArgumentList "/quiet", "/norestart" -Wait | |
| } | |
| # Cleanup | |
| Remove-Item -Path $installerPath | |
| Write-Output "$Name installation completed." | |
| } | |
| # Install each application | |
| foreach ($app in $installers.GetEnumerator()) { | |
| Install-Application -Name $app.Key -Url $app.Value | |
| } | |
| Write-Output "All applications have been installed." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| :: Check if the script is being run with administrator privileges | |
| net session >nul 2>&1 | |
| if %errorLevel% neq 0 ( | |
| echo Requesting administrative privileges... | |
| powershell.exe -Command "Start-Process cmd -ArgumentList '/c %~s0 %*' -Verb RunAs" | |
| exit /b | |
| ) | |
| :: Execute the PowerShell script | |
| powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& { | |
| # Ensure the script execution policy allows running scripts | |
| Set-ExecutionPolicy RemoteSigned -Scope Process -Force | |
| # Check for administrative privileges | |
| if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) | |
| { | |
| # Relaunch the script with elevated privileges | |
| $arguments = '-NoProfile -ExecutionPolicy Bypass -File ""$PSCommandPath' | |
| Start-Process PowerShell -Verb RunAs -ArgumentList $arguments | |
| exit | |
| } | |
| # Define the URLs for the installers | |
| $installers = @{ | |
| 'Nifty Project Management' = 'https://nifty-apps.s3.amazonaws.com/Nifty.exe' | |
| 'OpenVPN Client' = 'https://swupdate.openvpn.org/community/releases/OpenVPN-2.6.10-I003-amd64.msi' | |
| 'KeePass' = 'https://sourceforge.net/projects/keepass/files/KeePass%202.x/2.56/KeePass-2.56-Setup.exe' | |
| 'Slack' = 'https://downloads.slack-edge.com/desktop-releases/windows/x64/4.38.127/SlackSetup.exe' | |
| 'Chrome' = 'https://dl.google.com/chrome/install/latest/chrome_installer.exe' | |
| } | |
| # Function to download and install applications | |
| function Install-Application { | |
| param ( | |
| [string]$Name, | |
| [string]$Url | |
| ) | |
| if ($Name -eq 'KeePass') { | |
| $installerPath = '$env:USERPROFILE\Downloads\KeePass2-Latest.exe' | |
| Write-Output 'Downloading KeePass...' | |
| Invoke-WebRequest -UserAgent 'Wget' -Uri $Url -OutFile $installerPath | |
| } else { | |
| $installerPath = '$env:TEMP\$Name.exe' | |
| Write-Output 'Downloading $Name...' | |
| Invoke-WebRequest -Uri $Url -OutFile $installerPath | |
| } | |
| Write-Output 'Installing $Name...' | |
| if ($Name -eq 'OpenVPN Client') { | |
| Start-Process msiexec.exe -ArgumentList '/i', $installerPath, '/quiet', '/norestart' -Wait | |
| } else { | |
| Start-Process -FilePath $installerPath -ArgumentList '/quiet', '/norestart' -Wait | |
| } | |
| # Cleanup | |
| Remove-Item -Path $installerPath | |
| Write-Output '$Name installation completed.' | |
| } | |
| # Install each application | |
| foreach ($app in $installers.GetEnumerator()) { | |
| Install-Application -Name $app.Key -Url $app.Value | |
| } | |
| Write-Output 'All applications have been installed.' | |
| }" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment