Skip to content

Instantly share code, notes, and snippets.

@Dabolus
Last active September 29, 2017 13:45
Show Gist options
  • Save Dabolus/ec12fbd86e6cb0c7c1efca7a103ef6a2 to your computer and use it in GitHub Desktop.
Save Dabolus/ec12fbd86e6cb0c7c1efca7a103ef6a2 to your computer and use it in GitHub Desktop.
# 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 = "Black"
$Host.UI.RawUI.ForegroundColor = "Green"
Clear-Host
}
else {
# We are not running as an administrator, so relaunch as administrator
$str = "This script has to be executed as Administrator!"
$Host.UI.RawUI.WindowTitle = $str
Write-Host $str
# 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
}
### HELPER FUNCTIONS ###
function InstallStoreApp($id, $name) {
Write-Host "$name cannot be installed automatically."
Write-Host "Press a key when you're done installing..."
Start-Process "ms-windows-store://pdp/?ProductId=$id"
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
# Set up the Web Client
$webClient = New-Object System.NET.Webclient
$webClient.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2;)")
# Bypass the security policy to enable the execution of any script without confirmation...
Write-Host "Bypassing security policy..."
Set-ExecutionPolicy Bypass
# Enable developer mode to install applications without dev license
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"
# Download and execute the Chocolatey installation script
Write-Host "Downloading Chocolatey installation script..."
iex ($webClient.DownloadString('https://chocolatey.org/install.ps1'))
# Allow global confirmation to avoid giving consent to each installation
Write-Host "Enabling global confirmation on Chocolatey to avoid giving consent to each installation..."
choco feature enable -n allowGlobalConfirmation
### MEDIA ###
# Google Chrome
Write-Host "Installing Google Chrome..."
choco install googlechrome
# VLC
Write-Host "Installing VLC..."
choco install vlc
# IrfanView
Write-Host "Installing IrfanView..."
choco install irfanview
# paint.net
Write-Host "Installing paint.net"
choco install paint.net
# WinRAR
Write-Host "Installing WinRAR..."
choco install winrar
# Notepad++
Write-Host "Installing Notepad++"
choco install notepadplusplus
# Sublime Text 3
Write-Host "Installing Sublime Text 3..."
choco install sublimetext3
# Adobe Creative Cloud
Write-Host "Installing Adobe Creative Cloud..."
choco install adobe-creative-cloud
# Dropbox
Write-Host "Installing Dropbox"
choco install dropbox
# Google Drive
# Write-Host "Installing Google Drive..."
# choco install googledrive
# Java Development Kit
Write-Host "Installing Java Development Kit 8..."
choco install jdk8
# Telegram
Write-Host "Installing Telegram Desktop..."
choco install telegram
# WhatsApp
Write-Host "Installing WhatsApp..."
choco install whatsapp
# webp
Write-Host "Installing webp..."
choco install webp
# Facebook, Twitter and Plex
$apps = @([pscustomobject]@{id="9wzdncrfj2wl";name="Facebook"},
[pscustomobject]@{id="9wzdncrf0083";name="Messenger"},
[pscustomobject]@{id="9nblggh5l9xt";name="Instagram"},
[pscustomobject]@{id="9wzdncrfj140";name="Twitter"},
[pscustomobject]@{id="9wzdncrfj3q8";name="Plex"})
foreach ($app in $apps) {
InstallStoreApp $app."id" $app."name"
}
# Google Play Music Desktop Manager
Write-Host "Installing Google Play Music Desktop Manager..."
$json = $webClient.DownloadString("https://api.github.com/repos/MarshallOfSound/Google-Play-Music-Desktop-Player-UNOFFICIAL-/releases/latest") | ConvertFrom-Json
$searching = 1
for ($i = 0; $i -lt $json."assets".length -and $searching; $i++) {
if ($json."assets"[$i]."browser_download_url".EndsWith(".exe")) {
$webClient.DownloadFile($json."assets"[$i]."browser_download_url", "$env:temp\gpm.exe")
[System.Diagnostics.Process]::Start("$env:temp\gpm.exe")
Remove-Item "$env:temp\gpm.exe"
$searching = 0
}
}
### DEVELOPMENT ###
# Cmder
Write-Host "Installing cmder..."
choco install cmder
# OpenSSH
Write-Host "Installing OpenSSH..."
choco install openssh
# PuTTY
Write-Host "Installing PuTTY..."
choco install putty
# WinSCP
Write-Host "Installing WinSCP..."
choco install winscp
# MobaXTerm
Write-Host "Installing MobaXTerm..."
choco install mobaxterm
# Git
Write-Host "Installing git..."
choco install git
# NodeJS
Write-Host "Installing NodeJS..."
choco install nodejs
# Yarn
Write-Host "Installing Yarn..."
choco install yarn
# Python 2/3
Write-Host "Installing Python 2 and 3..."
choco install python2
choco install python3
# PHP
Write-Host "Installing PHP..."
choco install php
# Ruby
Write-Host "Installing Ruby..."
choco install ruby
# Perl
Write-Host "Installing Perl..."
choco install strawberryperl
# Nodemon
Write-Host "Installing nodemon..."
yarn global add nodemon
# Express
Write-Host "Installing Express..."
yarn global add express
yarn global add express-generator
# RedBird
Write-Host "Installing RedBird..."
yarn global add redbird
# Sails.js
Write-Host "Installing Sails.js..."
yarn global add sails
# Bower
Write-Host "Installing Bower..."
yarn global add bower
# Angular CLI
Write-Host "Installing Angular CLI..."
yarn global add @angular/cli
# Create React App
Write-Host "Installing create-react-app..."
yarn global add create-react-app
# Preact CLI
Write-Host "Installing Preact CLI..."
yarn global add preact-cli
# Polymer CLI
Write-Host "Installing Polymer CLI..."
yarn global add polymer-cli
# Webpack
Write-Host "Installing Webpack..."
yarn global add webpack
# Babel
Write-Host "Installing Babel..."
yarn global add babel-cli babel-polyfill babel-preset-env babel-preset-react
# TypeScript
Write-Host "Installing TypeScript..."
yarn global add typescript
# Pug/Jade
Write-Host "Installing Pug (Jade)..."
yarn global add pug
# SASS/SCSS
Write-Host "Installing SASS/SCSS..."
gem install sass
# JetBrains Toolbox
Write-Host "Installing JetBrains Toolbox..."
choco install jetbrainstoolbox
#### SYSTEM UPDATE ####
# Import the assembly to decompress zip files
Add-Type -AssemblyName System.IO.Compression.FileSystem
# Download and import the PSWindowsUpdate module
$webClient.DownloadFile("https://gallery.technet.microsoft.com/scriptcenter/2d191bcd-3308-4edd-9de2-88dff796b0bc/file/41459/47/PSWindowsUpdate.zip", "$env:temp\PSWindowsUpdate.zip")
[System.IO.Compression.ZipFile]::ExtractToDirectory("$env:temp\PSWindowsUpdate.zip", "$env:windir\System32\WindowsPowerShell\v1.0\Modules\")
Remove-Item "$env:temp\PSWindowsUpdate.zip"
Import-Module PSWindowsUpdate
# Register the Microsoft Update Service on the computer
Add-WUServiceManager -ServiceID 7971f918-a847-4430-9279-4a52d1efe18d
# Download and install all the available Microsoft Updates
Get-WUInstall -MicrosoftUpdate -AcceptAll
# All done! Reboot the PC.
Write-Host "All done! I'm going to reboot your PC to make sure that any update is applied correctly."
Write-Host -NoNewLine "Save your work and then press any key to reboot..."
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Restart-Computer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment