---
title: "Query-Package"
---
Tests whether a universal package exists and optionally extracts its metadata.
UPack::Query-Package(
[From: <text>],
Name: <text>,
Version: <text>,
NewVersion: <text>,
[Reason: <text>],
[PackageFile: <text>],
[Feed: <text>],
[EndpointUrl: <text>],
[UserName: <text>],
[Password: <text>],
[ApiKey: <text>],
[Exists: <true/false>],
[Metadata: <%(key1: value1, ...)>]
);
Name | Format | Script Usage | Usage Notes |
---|---|---|---|
Package source | text | From | |
☆ Package name | text | Name | This argument is required. |
☆ Package version | text | Version | Default value is "latest". This argument is required. |
☆ New version | text | NewVersion | This argument is required. |
Reason | text | Reason | Value note: "Unspecified". |
Package file | text | PackageFile | When specified, FeedUrl, UserName, Password, PackageName, and PackageVersion are ignored. |
Feed name | text | Feed | Not specifying will "Use Feed from package source". |
API endpoint URL | text | EndpointUrl | Not specifying will "Use URL from package source". |
ProGet user name | text | UserName | The name of a user in ProGet that can access this feed. Not specifying will "Use user name from package source". |
ProGet password | text | Password | The password of a user in ProGet that can access this feed. Not specifying will "Use password from package source". |
ProGet API Key | text | ApiKey | An API Key that can access this feed. Not specifying will "Use API Key from package source". |
⇒ Package exists | true/false | Exists | When specified, this string variable will be set to "true" if the package exists or "false" if it does not. e.g. $PackageExists". |
⇒ Package metadata | %(key1: value1, ...) | Metadata | When specified, this map variable will be assigned containing all of the package's metadata. If the package does not exist this value is not defined. |
# test whether a package exists in a feed and capture its metadata
Query-Package
(
Credentials: MyExternalFeed,
PackageName: Group/Package,
Exists => $exists,
Metadata => %packageData
);
if $exists
{
Log-Debug 'Package $(%packageData.name) exists. Latest version is $(%packageData.version).';
}