Edit

Share via


Install-PSResource

Installs resources from a registered repository.

Syntax

Install-PSResource
       [-Name] <String[]>
       [-Version <String>]
       [-Prerelease]
       [-Repository <String[]>]
       [-Credential <PSCredential>]
       [-Scope <ScopeType>]
       [-TemporaryPath <String>]
       [-TrustRepository]
       [-Reinstall]
       [-Quiet]
       [-AcceptLicense]
       [-NoClobber]
       [-SkipDependencyCheck]
       [-AuthenticodeCheck]
       [-PassThru]
       [-WhatIf]
       [-Confirm]
       [<CommonParameters>]
Install-PSResource
       [-Repository <String[]>]
       [-Credential <PSCredential>]
       [-Scope <ScopeType>]
       [-TemporaryPath <String>]
       [-TrustRepository]
       [-Reinstall]
       [-Quiet]
       [-AcceptLicense]
       [-NoClobber]
       [-SkipDependencyCheck]
       [-AuthenticodeCheck]
       [-PassThru]
       [-InputObject] <PSResourceInfo[]>
       [-WhatIf]
       [-Confirm]
       [<CommonParameters>]
Install-PSResource
       [-Credential <PSCredential>]
       [-Scope <ScopeType>]
       [-TemporaryPath <String>]
       [-TrustRepository]
       [-Reinstall]
       [-Quiet]
       [-AcceptLicense]
       [-NoClobber]
       [-SkipDependencyCheck]
       [-AuthenticodeCheck]
       [-PassThru]
       -RequiredResourceFile <String>
       [-WhatIf]
       [-Confirm]
       [<CommonParameters>]
Install-PSResource
       [-Credential <PSCredential>]
       [-Scope <ScopeType>]
       [-TemporaryPath <String>]
       [-TrustRepository]
       [-Reinstall]
       [-Quiet]
       [-AcceptLicense]
       [-NoClobber]
       [-SkipDependencyCheck]
       [-AuthenticodeCheck]
       [-PassThru]
       -RequiredResource <Object>
       [-WhatIf]
       [-Confirm]
       [<CommonParameters>]

Description

This cmdlet installs resources from a registered repository to an installation path on a machine. By default, the cmdlet doesn't return any object. Other parameters allow you to specify the repository, scope, and version for a resource, and suppress license prompts.

This cmdlet combines the functions of the Install-Module and Install-Script cmdlets from PowerShellGet v2.

Install-PSResource doesn't load the newly installed module into the current session. You must import the new version or start a new session to use the updated module. For more information, see Import-Module.

Note

Install-PSResource doesn't install dependent resources from repositories that use the NuGet v3 protocol. You must install the dependent resources individually. We intend to add this feature in a future release.

Examples

Example 1

Installs the latest stable (non-prerelease) version of the Az module from the PowerShell Gallery.

Install-PSResource Az -Repository PSGallery

The Az module is a meta-module that includes all the Az PowerShell modules as dependencies. This command installs the Az module and all its dependencies.

Example 2

Installs the latest stable Az module within the between versions 7.3.0 and 8.3.0.

Install-PSResource Az -Version '[7.3.0, 8.3.0]'

Example 3

Installs the latest stable version of the Az module. When the Reinstall parameter is used, the cmdlet writes over any previously installed version.

Install-PSResource Az -Reinstall

Example 4

Installs the PSResources specified in the psd1 file.

Install-PSResource -RequiredResourceFile myRequiredModules.psd1

Example 5

Installs the PSResources specified in the hashtable.

Install-PSResource -RequiredResource  @{
    TestModule = @{
        version = '[0.0.1,1.3.0]'
        repository = 'PSGallery'
      }
    TestModulePrerelease = @{
        version = '[0.0.0,0.0.5]'
        repository = 'PSGallery'
        prerelease = 'true'
    }
    TestModule99 = @{}
}

Parameters

-AcceptLicense

Specifies that the resource should accept any request to accept the license agreement. This suppresses prompting if the module mandates that a user accept the license agreement.

Type:SwitchParameter
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AuthenticodeCheck

Validates Authenticode signatures and catalog files on Windows.

Type:SwitchParameter
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Credential

Optional credentials used when accessing a repository.

Type:PSCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-InputObject

Used for pipeline input.

Type:Microsoft.PowerShell.PSResourceGet.UtilClasses.PSResourceInfo[]
Aliases:ParentResource
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Name

The name of one or more resources to install.

Type:String[]
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-NoClobber

Prevents installing a package that contains cmdlets that already exist on the machine.

Type:SwitchParameter
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-PassThru

When specified, outputs a PSResourceInfo object for the saved resource.

Type:SwitchParameter
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Prerelease

When specified, includes prerelease versions in search results returned.

Type: