Created
September 15, 2015 05:18
-
-
Save bahamut45/a476f171239380a3a17f to your computer and use it in GitHub Desktop.
Installation Automatique de chocolatey
This file contains 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
######################### | |
# Autoinstall script using chocolatey | |
######################### | |
function Download-File { | |
param ( | |
[string]$url, | |
[string]$file | |
) | |
Write-Host "Downloading $url to $file" -ForegroundColor Yellow; | |
$downloader = New-Object System.Net.WebClient | |
$downloader.Proxy.Credentials=[System.Net.CredentialCache]::DefaultNetworkCredentials; | |
$downloader.DownloadFile($url, $file) | |
} | |
# Require .NET 4.0 | |
if(!(Test-Path "hklm:\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SKUs\.NETFramework,Version=v4.0")) | |
{ | |
$TempFolder = Join-Path $env:temp 'autoDotNet4.0' | |
#Check if TempFolder not exist, create directory | |
if(!(Test-Path $TempFolder)) | |
{ | |
New-Item -path $TempFolder -type directory | |
} | |
Write-Host "" | |
$url ="http://tiny.cc/e8q90x" | |
$file = Join-Path $TempFolder 'dotNetFx40_Full_x86_x64.exe' | |
Download-File $url "$file" | |
$args = " /q /norestart" | |
Write-Host "Installing .NET framework v4.0" -ForegroundColor Yellow; | |
# Beginning the Installation | |
Start-Process -FilePath $file -ArgumentList $args -Wait | |
# Delete $TempFolder | |
Remove-Item $TempFolder -recurse | |
} | |
else | |
{ | |
Write-Host "Microsoft .Net 4.0 Framework is already installed on your machine." -ForegroundColor Green; | |
} | |
################# | |
#Modify this line to change packages | |
################# | |
$items = @( | |
"atom", | |
"babun -version 1.2.0", | |
"cmder.portable -pre", | |
"freefilesync", | |
"clover", | |
"keepass", | |
"keepass-keepasshttp", | |
"keepass-langfiles", | |
"teamviewer", | |
"chocolateygui", | |
"filebot", | |
"7zip", | |
"adobereader", | |
"javaruntime", | |
"googlechrome", | |
"firefox", | |
"opera", | |
"teracopy", | |
"wget", | |
"hg", | |
"poedit", | |
"disableuac", | |
"pidgin" | |
) | |
################# | |
# Create packages.config based on passed arguments | |
################# | |
$xml = '<?xml version="1.0" encoding="utf-8"?>'+ "`n" +'<packages>' + "`n" | |
foreach ($item in $items) | |
{ | |
$xml += "`t" +'<package id="' + $item + '"/>' + "`n" | |
} | |
$xml += '</packages>' | |
$file = ([system.environment]::getenvironmentvariable("userprofile") + "\packages.config") | |
$xml | Out-File $file | |
################# | |
# Check and Install chocolatey | |
################# | |
$chocoPath = 'C:\ProgramData\Chocolatey' | |
$chocoExePath = Join-Path $chocoPath 'bin' | |
If (!(Test-Path $chocoPath)) | |
{ | |
iex ((New-Object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) | |
if ($($env:Path).ToLower().Contains($($chocoExePath).ToLower()) -eq $false) | |
{ | |
$env:Path = [Environment]::GetEnvironmentVariable('Path',[System.EnvironmentVariableTarget]::Machine); | |
} | |
} | |
else | |
{ | |
Write-Host "Chocolatey is already installed on your machine." -ForegroundColor Green; | |
} | |
################# | |
# Install packages with cinst | |
################# | |
#cinst $file | |
################# | |
# Delete packages.config | |
################# | |
Remove-Item $file | |
################# | |
# Add module PinnedApplication | |
################# | |
$url = "https://gist.githubusercontent.com/jhorsman/0e4655da25c3e1700cb2/raw/6a514c69c67cf5ba41a9a9907b311ce57a2f508c/PinnedApplications.psm1" | |
$powershell_path = $env:PSModulePath.split(";")[0] | |
if(!(Test-Path $powershell_path)) | |
{ | |
New-Item -path $powershell_path -type directory | |
} | |
$file = Join-Path $powershell_path "PinnedApplications.psm1" | |
if(!(Test-Path $file)) | |
{ | |
Download-File $url $file | |
} | |
#$ErrorActionPreference = "SilentlyContinue" | |
Import-Module $file | |
$ie = Join-Path $env:APPDATA "Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Internet Explorer.lnk" | |
Set-PinnedApplication -Action UnPinFromTaskbar -FilePath "$ie" | |
Set-PinnedApplication -Action PinToTaskbar -FilePath "C:\WINDOWS\system32\notepad.exe" |
This file contains 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 | |
Powershell.exe -executionpolicy remotesigned -file win_autoinstall_chocolatey.ps1 | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment