Difference between revisions of "Windows package manager"

From Ever changing code
Jump to navigation Jump to search
 
(12 intermediate revisions by the same user not shown)
Line 2: Line 2:


= Install =
= Install =
<source lang="ps1">
<syntaxhighlightjs lang="powershell">
#List execution policies
# List execution policies
Get-ExecutionPolicy -List
Get-ExecutionPolicy -List


#Windows Server  
# Windows Server  
Update-ExecutionPolicy -Policy Unrestricted
Update-ExecutionPolicy -Policy Unrestricted


#Windows 10
# Windows 10
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
Set-ExecutionPolicy Unrestricted -Scope LocalMachine
Set-ExecutionPolicy Unrestricted -Scope LocalMachine


#Install Chocolatey
# Install Chocolatey
iex ((new-object net.webclient).DownloadString("http://chocolatey.org/install.ps1"))  
## Short version
#Reload profile
iex ((new-object net.webclient).DownloadString("http://chocolatey.org/install.ps1"))
 
## Full version
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
 
## Reload profile
. $profile
. $profile


Line 22: Line 27:
alias iwr #Alias          iwr -> Invoke-WebRequest  
alias iwr #Alias          iwr -> Invoke-WebRequest  
alias iex #Alias          iex -> Invoke-Expression
alias iex #Alias          iex -> Invoke-Expression
</source>
</syntaxhighlightjs>


= Usage =
= Usage =
<source lang="powershell">
<syntaxhighlightjs lang="powershell">
# Install
choco install <pkg|packages.config> [<pkg2> <pkgN>] [<options/switches>]
choco install <pkg|packages.config> [<pkg2> <pkgN>] [<options/switches>]
cinst <pkg|packages.config> [<pkg2> <pkgN>] [<options/switches>]
cinst         <pkg|packages.config> [<pkg2> <pkgN>] [<options/switches>]


# Unistall
choco uninstall <pkg|all> [pkg2 pkgN] [options/switches]
choco uninstall <pkg|all> [pkg2 pkgN] [options/switches]
cuninst <pkg|all> [pkg2 pkgN] [options/switches]
cuninst <pkg|all> [pkg2 pkgN] [options/switches]


# List packages
choco list --local-only
choco list --local-only
</source>
choco version all # deprecated in version 1.0.0
 
# Upgrade
choco upgrade all
</syntaxhighlightjs>


= Install packages =
= Install packages =
Often packages require to run .ps1 installation steps and you will be prompted with: "''The package sublimetext2 wants to run 'chocolateyInstall.ps1'. Note: If you don't run this script, the installation will fail. Note: To confirm automatically next time, use '-y' or consider: choco feature enable -n allowGlobalConfirmation.''. So use commands to achieve this:
Often packages require to run .ps1 installation steps and you will be prompted with: "''The package sublimetext2 wants to run 'chocolateyInstall.ps1'. Note: If you don't run this script, the installation will fail. Note: To confirm automatically next time, use '-y' or consider: choco feature enable -n allowGlobalConfirmation.''. So use commands to achieve this:


<source lang="powershell">
<syntaxhighlightjs lang="powershell">
choco feature enable -n allowGlobalConfirmation #one time off
choco feature enable -n allowGlobalConfirmation #one time off
choco install -y notepadplusplus #per package
choco install -y notepadplusplus               #per package
</source>
</syntaxhighlightjs>




<source lang="powershell">
<syntaxhighlightjs lang="powershell">
cinst putty 7zip postman
cinst putty 7zip postman
cinst googlechrome firefox
choco install virtualbox
choco install minikube kubernetes-cli
cinst git-credential-manager-for-windows
cinst git-credential-manager-for-windows
cinst poshgit #git prompt in PowerShell teminal
cinst poshgit # git prompt in PowerShell teminal
cinst console-devel
cinst console-devel
cinst notepadplusplus sublimetext2 atom
cinst vscode notepadplusplus sublimetext2 atom #text editors
cinst vlc
cinst winmerge # add kdiff3
cinst winmerge #add kdiff3
cinst googlechrome firefox
cinst sourcetree
cinst sourcetree
cinst resharper
cinst visualstudiocode
cinst nodejs.install
cinst nodejs.install
cinst dotpeek
cinst dotpeek
cinst fiddler4 #SSL packet inspection termination point and logging  
cinst fiddler4 # SSL packet inspection termination point and logging  
choco install dotnetcore-sdk            # .Net Core SDK
choco install dotnetcore-windowshosting # ASP.NET Core Module for IIS, enabling running of ASP.NET Core applications


choco install dotnetcore-sdk            #.Net Core SDK
# Desktop
choco install dotnetcore-windowshosting #ASP.NET Core Module for IIS, enabling running of ASP.NET Core applications
choco install f.lux.install
 
cinst vlc
#Other
Install-ChocolateyVsixPackage VS-Color-Output https://visualstudiogallery.msdn.microsoft.com/f4d9c2b5-d6d7-4543-a7a5-2d7ebabc2496/file/63103/9/VSColorOutput.vsix


#Outdated
# Outdated
#cinst git-credential-winstore #old use: Git Credential Manager for Windows
# cinst git-credential-winstore # old use: Git Credential Manager for Windows
</source>
</syntaxhighlightjs>


= Install .net core =
= Install .net core =
<source lang="powershell">
<syntaxhighlightjs lang="powershell">
powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -useb 'https://dot.net/v1/dotnet-install.ps1'))) <additional install-script args>"
powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -useb 'https://dot.net/v1/dotnet-install.ps1'))) <additional install-script args>"
</source>
</syntaxhighlightjs>
== References ==
== References ==
* [https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script dotnet-install-script] Microsoft docs
* [https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script dotnet-install-script] Microsoft docs


= Install IIS =
= Install IIS =
Install IIS with PowerShell on Windows Server 2016 / VPS
Install IIS with PowerShell on Windows Server 2016 / VPS / 2019
<source lang="powershell">
<syntaxhighlightjs lang="powershell">
# enable IIS role
# enable IIS role
Set-ExecutionPolicy Bypass -Scope Process
Set-ExecutionPolicy Bypass -Scope Process
Get-WindowsOptionalFeature -Online | where FeatureName -like 'IIS-*' #check online for available features
Get-WindowsOptionalFeature -Online | where FeatureName -like 'IIS-*' # check online for available features
Get-WindowsFeature -Name Web* | Where-Object Installed              #check installed web related features
Get-WindowsFeature -Name Web* | Where-Object Installed              # check installed web related features
Install-WindowsFeature -Name Web-Server -IncludeManagementTools
Install-WindowsFeature -Name Web-Server -IncludeManagementTools
Install-WindowsFeature -Name Web-Server -IncludeManagementTools -IncludeAllSubFeature  
Install-WindowsFeature -Name Web-Server -IncludeManagementTools -IncludeAllSubFeature  
</source>
Disable-WindowsOptionalFeature -Online -FeatureName IIS-WebDAV      # disable IIS sub-feature (uninstall)
</syntaxhighlightjs>


= Windows desktop developer settings =
= Windows desktop developer settings =
<source lang="powershell">
<syntaxhighlightjs lang="powershell">
#Set-WinUserLanguageList -LanguageList en-GB
# Set-WinUserLanguageList -LanguageList en-GB
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar
Enable-RemoteDesktop
Enable-RemoteDesktop
#Set-StartScreenOptio=ns -EnableBootToDesktop
# Set-StartScreenOptio=ns -EnableBootToDesktop
#Move-LibraryDirectory "Personal" "$env:UserProfile\<userName>\documents"
# Move-LibraryDirectory "Personal" "$env:UserProfile\<userName>\documents"
#Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar -EnableOpenFileExplorerToQuickAccess -EnableShowRecentFilesInQuickAccess -EnableShowFrequentFoldersInQuickAccess -EnableExpandToOpenFolder
# Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar -EnableOpenFileExplorerToQuickAccess -EnableShowRecentFilesInQuickAccess -EnableShowFrequentFoldersInQuickAccess -EnableExpandToOpenFolder
#Set-TaskbarOptions -Size Small -Lock -Dock Top -Combine Always
# Set-TaskbarOptions -Size Small -Lock -Dock Top -Combine Always
#Install-WindowsUpdate -AcceptEula
# Install-WindowsUpdate -AcceptEula
</source>
</syntaxhighlightjs>


= Resources =
= Resources =
*[https://github.com/chocolatey/choco/wiki Chocolatey - Software Management for Windows] GitHub wiki
*[https://github.com/chocolatey/choco/wiki Chocolatey - Software Management for Windows] GitHub wiki

Latest revision as of 04:49, 10 March 2020

Chocolatey is a package manager for Windows like apt-get or yum but for Windows. With all of this in mind, think of Chocolatey as a framework that you can build on top of. Chef, Puppet, Boxstarter, PowerShell DSC, Ansible, Saltstack, etc all have ways for using Chocolatey to ensure the state of a computer and packages installed. Even Microsoft has decided to use Chocolatey's framework with the PowerShell PackageManagement / OneGet package manager aggregator.

Install

<syntaxhighlightjs lang="powershell">

  1. List execution policies

Get-ExecutionPolicy -List

  1. Windows Server

Update-ExecutionPolicy -Policy Unrestricted

  1. Windows 10

Set-ExecutionPolicy Unrestricted -Scope CurrentUser Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force Set-ExecutionPolicy Unrestricted -Scope LocalMachine

  1. Install Chocolatey
    1. Short version

iex ((new-object net.webclient).DownloadString("http://chocolatey.org/install.ps1"))

    1. Full version

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

    1. Reload profile

. $profile

  1. Explanation

alias iwr #Alias iwr -> Invoke-WebRequest alias iex #Alias iex -> Invoke-Expression </syntaxhighlightjs>

Usage

<syntaxhighlightjs lang="powershell">

  1. Install

choco install <pkg|packages.config> [<pkg2> <pkgN>] [<options/switches>] cinst <pkg|packages.config> [<pkg2> <pkgN>] [<options/switches>]

  1. Unistall

choco uninstall <pkg|all> [pkg2 pkgN] [options/switches] cuninst <pkg|all> [pkg2 pkgN] [options/switches]

  1. List packages

choco list --local-only choco version all # deprecated in version 1.0.0

  1. Upgrade

choco upgrade all </syntaxhighlightjs>

Install packages

Often packages require to run .ps1 installation steps and you will be prompted with: "The package sublimetext2 wants to run 'chocolateyInstall.ps1'. Note: If you don't run this script, the installation will fail. Note: To confirm automatically next time, use '-y' or consider: choco feature enable -n allowGlobalConfirmation.. So use commands to achieve this:

<syntaxhighlightjs lang="powershell"> choco feature enable -n allowGlobalConfirmation #one time off choco install -y notepadplusplus #per package </syntaxhighlightjs>


<syntaxhighlightjs lang="powershell"> cinst putty 7zip postman cinst googlechrome firefox choco install virtualbox choco install minikube kubernetes-cli cinst git-credential-manager-for-windows cinst poshgit # git prompt in PowerShell teminal cinst console-devel cinst vscode notepadplusplus sublimetext2 atom #text editors cinst winmerge # add kdiff3 cinst sourcetree cinst nodejs.install cinst dotpeek cinst fiddler4 # SSL packet inspection termination point and logging choco install dotnetcore-sdk # .Net Core SDK choco install dotnetcore-windowshosting # ASP.NET Core Module for IIS, enabling running of ASP.NET Core applications

  1. Desktop

choco install f.lux.install cinst vlc

  1. Outdated
  2. cinst git-credential-winstore # old use: Git Credential Manager for Windows

</syntaxhighlightjs>

Install .net core

<syntaxhighlightjs lang="powershell"> powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -useb 'https://dot.net/v1/dotnet-install.ps1'))) <additional install-script args>" </syntaxhighlightjs>

References

Install IIS

Install IIS with PowerShell on Windows Server 2016 / VPS / 2019 <syntaxhighlightjs lang="powershell">

  1. enable IIS role

Set-ExecutionPolicy Bypass -Scope Process Get-WindowsOptionalFeature -Online | where FeatureName -like 'IIS-*' # check online for available features Get-WindowsFeature -Name Web* | Where-Object Installed # check installed web related features Install-WindowsFeature -Name Web-Server -IncludeManagementTools Install-WindowsFeature -Name Web-Server -IncludeManagementTools -IncludeAllSubFeature Disable-WindowsOptionalFeature -Online -FeatureName IIS-WebDAV # disable IIS sub-feature (uninstall) </syntaxhighlightjs>

Windows desktop developer settings

<syntaxhighlightjs lang="powershell">

  1. Set-WinUserLanguageList -LanguageList en-GB

Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar Enable-RemoteDesktop

  1. Set-StartScreenOptio=ns -EnableBootToDesktop
  2. Move-LibraryDirectory "Personal" "$env:UserProfile\<userName>\documents"
  3. Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar -EnableOpenFileExplorerToQuickAccess -EnableShowRecentFilesInQuickAccess -EnableShowFrequentFoldersInQuickAccess -EnableExpandToOpenFolder
  4. Set-TaskbarOptions -Size Small -Lock -Dock Top -Combine Always
  5. Install-WindowsUpdate -AcceptEula

</syntaxhighlightjs>

Resources