---
title: "Ensure PowerShell Repository"
---
Ensures that the specified PowerShell Repository is registered.
Ensure-PsRepository(
Name: <text>,
SourceLocation: <text>,
[InstallationPolicy: <text>],
[Exists: <true/false>],
[PackageManagementProvider: <text>],
[Parameters: <%(key1: value1, ...)>],
[Verbose: <true/false>],
[DebugLogging: <true/false>],
[PreferWindowsPowerShell: <text>]
);
This operation may be prefixed with PowerShell::
, although this is a built-in namespace and isn't really necessary.
Name | Format | Script Usage | Usage Notes |
---|---|---|---|
☆ Name | text | Name | This argument is required. |
☆ Source Location | text | SourceLocation | This argument is required. |
Installation Policy | text | InstallationPolicy | Use "Trusted" or "Untrusted". |
Exists | true/false | Exists | Default value is "True". |
Package Management Provider | text | PackageManagementProvider | |
Parameters | %(key1: value1, ...) | Parameters | Additional parameters to pass to Install-Module. Example: %(DestinationPath: C:\hdars\1000.txt, Contents: test file ensured). Value note: "%(...)". |
Verbose | true/false | Verbose | Default value is "False". |
Debug Logging | true/false | DebugLogging | Default value is "False". |
Prefer Windows PowerShell | text | PreferWindowsPowerShell | When true, the script will be run using Windows PowerShell 5.1 where available. When false or on Linux (or on Windows systems without PowerShell 5.1 installed), the script will be run using PowerShell Core instead. Default value is "$PreferWindowsPowerShell". |
Note: An argument may be explicitly converted to an integral type by prefixing the value with [type::<typeName>], where <typeName> is one of: int, uint, long, ulong, double, decimal. Normally this conversion is performed automatically and this is not necessary.
# ensures the existence of a repository on the server
Ensure-PsRepository(
Name: internal-powershell,
SourceLocation: https://proget/nuget/internal-powershell/,
InstallationPolicy: Trusted
Exists: true)