Install-ChocolateyPackage

Install-ChocolateyPackage

Install-ChocolateyPackage

:choco-info: NOTE

Administrative Access Required.

Installs software into “Programs and Features” based on a remote file download. Use Install-ChocolateyInstallPackage when local or embedded file.

Building packages for an organization or for use internally? You want to use Install-ChocolateyINSTALLPackage instead of this method (see links below).

Syntax

Install-ChocolateyPackage `
  -PackageName <String> `
  [-FileType <String>] `
  [-SilentArgs <String[]>] `
  [-Url <String>] `
  [-Url64bit <String>] `
  [-ValidExitCodes <Object>] `
  [-Checksum <String>] `
  [-ChecksumType <String>] `
  [-Checksum64 <String>] `
  [-ChecksumType64 <String>] `
  [-Options <Hashtable>] `
  [-File <String>] `
  [-File64 <String>] `
  [-UseOnlyPackageSilentArguments] `
  [-UseOriginalLocation] `
  [-BeforeInstall <ScriptBlock>] `
  [-IgnoredArguments <Object[]>] [<CommonParameters>]

Description

This will download a native installer from a url and install it on your machine. Has error handling built in.

If you are embedding the file(s) directly in the package (or do not need to download a file first), use Install-ChocolateyInstallPackage instead.

Building packages for an organization or for use internally? You want to use Install-ChocolateyINSTALLPackage instead of this method (see links below).

Notes

This command will assert UAC/Admin privileges on the machine.

This is a native installer wrapper function. A “true” package will contain all the run time files and not an installer. That could come pre-zipped and require unzipping in a PowerShell script. Chocolatey works best when the packages contain the software it is managing. Most software in the Windows world comes as installers and Chocolatey understands how to work with that, hence this wrapper function.

Chocolatey works best when the packages contain the software it is managing and doesn’t require downloads. However most software in the Windows world requires redistribution rights and when sharing packages publicly (like on the community feed), maintainers may not have those aforementioned rights. Chocolatey understands how to work with that, hence this function. You are not subject to this limitation with internal packages.

Aliases

None

Examples

EXAMPLE 1


$packageName= 'bob'
$toolsDir   = "$(Split-Path -Parent $MyInvocation.MyCommand.Definition)"
$url        = 'https://somewhere.com/file.msi'
$url64      = 'https://somewhere.com/file-x64.msi'

$packageArgs = @{
  packageName   = $packageName
  fileType      = 'msi'
  url           = $url
  url64bit      = $url64
  silentArgs    = "/qn /norestart"
  validExitCodes= @(0, 3010, 1641)
  softwareName  = 'Bob*'
  checksum      = '12345'
  checksumType  = 'sha256'
  checksum64    = '123356'
  checksumType64= 'sha256'
}

Install-ChocolateyPackage @packageArgs

EXAMPLE 2


$packageName= 'bob'
$toolsDir   = "$(Split-Path -Parent $MyInvocation.MyCommand.Definition)"
$url        = 'https://somewhere.com/file.msi'
$url64      = 'https://somewhere.com/file-x64.msi'


$packageArgs = @{
  packageName   = $packageName
  fileType      = 'msi'
  url           = $url
  url64bit      = $url64
  silentArgs    = "/qn /norestart MSIPROPERTY=`"true`""
  validExitCodes= @(0, 3010, 1641)
  softwareName  = 'Bob*'
  checksum      = '12345'
  checksumType  = 'sha256'
  checksum64    = '123356'
  checksumType64= 'sha256'
}

Install-ChocolateyPackage @packageArgs

EXAMPLE 3


$packageName= 'bob'
$toolsDir   = "$(Split-Path -Parent $MyInvocation.MyCommand.Definition)"
$urlTransform = 'https://somewhere.com/file.mst'
$mstFileLocation = Join-Path $toolsDir 'transform.mst'

Get-ChocolateyWebFile -PackageName 'bob' `
                      -Url $urlTransform -FileFullPath $mstFileLocation `
                      -Checksum '1234' -ChecksumType 'sha256'

$packageArgs = @{
  packageName   = $packageName
  fileType      = 'msi'
  file          = $fileLocation
  silentArgs    = "/qn /norestart TRANSFORMS=`"$mstFileLocation`""
  validExitCodes= @(0, 3010, 1641)
  softwareName  = 'Bob*'
}

Install-ChocolateyInstallPackage @packageArgs

EXAMPLE 4


Install-ChocolateyPackage 'StExBar' 'msi' '/quiet' `
 'http://stexbar.googlecode.com/files/StExBar-1.8.3.msi' `
 'http://stexbar.googlecode.com/files/StExBar64-1.8.3.msi'

EXAMPLE 5


Install-ChocolateyPackage 'mono' 'exe' '/SILENT' `
 'http://somewhere/something.exe' -ValidExitCodes @(0,21)

EXAMPLE 6


Install-ChocolateyPackage 'ruby.devkit' 'exe' '/SILENT' `
 'http://cdn.rubyinstaller.org/archives/devkits/DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe' `
 'http://cdn.rubyinstaller.org/archives/devkits/DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe' `
 -checksum '9383f12958aafc425923e322460a84de' -checksumType 'md5' `
 -checksum64 'ce99d873c1acc8bffc639bd4e764b849'

EXAMPLE 7

Install-ChocolateyPackage 'bob' 'exe' '/S' 'https://somewhere/bob.exe' 'https://somewhere/bob-x64.exe'

EXAMPLE 8


$options =
@{
  Headers = @{
    Accept = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
    'Accept-Charset' = 'ISO-8859-1,utf-8;q=0.7,*;q=0.3';
    'Accept-Language' = 'en-GB,en-US;q=0.8,en;q=0.6';
    Cookie = 'requiredinfo=info';
    Referer = 'https://somelocation.com/';
  }
}

Install-ChocolateyPackage -PackageName 'package' -FileType 'exe' -SilentArgs '/S' 'https://somelocation.com/thefile.exe' -Options $options

Inputs

None

Outputs

None

Parameters

-PackageName <String>

PropertyValue
Aliases
Required?true
Position?1
Default Value
Accept Pipeline Input?false

-FileType [<String>]

PropertyValue
AliasesinstallerType, installType
Required?false
Position?2
Default Valueexe
Accept Pipeline Input?false

-SilentArgs [<String[]>]

PropertyValue
Aliases
Required?false
Position?3
Default Value
Accept Pipeline Input?false

-Url [<String>]

PropertyValue
Aliases
Required?false
Position?4
Default Value
Accept Pipeline Input?false

-Url64bit [<String>]

PropertyValue
Aliasesurl64
Required?false
Position?5
Default Value
Accept Pipeline Input?false

-ValidExitCodes [<Object>]

PropertyValue
Aliases
Required?false
Position?named
Default Value@(0)
Accept Pipeline Input?false

-Checksum [<String>]

PropertyValue
Aliases
Required?false
Position?named
Default Value
Accept Pipeline Input?false

-ChecksumType [<String>]

PropertyValue
Aliases
Required?false
Position?named
Default Value
Accept Pipeline Input?false

-Checksum64 [<String>]

PropertyValue
Aliases
Required?false
Position?named
Default Value
Accept Pipeline Input?false

-ChecksumType64 [<String>]

PropertyValue
Aliases
Required?false
Position?named
Default Value
Accept Pipeline Input?false

-Options [<Hashtable>]

PropertyValue
Aliases
Required?false
Position?named
Default Value@{Headers = @{} }
Accept Pipeline Input?false

-File [<String>]

PropertyValue
AliasesfileFullPath
Required?false
Position?named
Default Value
Accept Pipeline Input?false

-File64 [<String>]

PropertyValue
AliasesfileFullPath64
Required?false
Position?named
Default Value
Accept Pipeline Input?false

-UseOnlyPackageSilentArguments

PropertyValue
AliasesuseOnlyPackageSilentArgs
Required?false
Position?named
Default ValueFalse
Accept Pipeline Input?false

-UseOriginalLocation

PropertyValue
Aliases
Required?false
Position?named
Default ValueFalse
Accept Pipeline Input?false

-BeforeInstall [<ScriptBlock>]

PropertyValue
Aliases
Required?false
Position?named
Default Value
Accept Pipeline Input?false

-IgnoredArguments [<Object[]>]

PropertyValue
Aliases
Required?false
Position?named
Default Value
Accept Pipeline Input?false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters http://go.microsoft.com/fwlink/p/?LinkID=113216 .

Function Reference

:choco-info: NOTE

This documentation has been automatically generated from Import-Module "$env:ChocolateyInstall\helpers\chocolateyInstaller.psm1" -Force; Get-Help Install-ChocolateyPackage -Full.

View the source for Install-ChocolateyPackage