diff --git a/.ci/releaseBuild.yml b/.ci/releaseBuild.yml
new file mode 100644
index 0000000..b61f697
--- /dev/null
+++ b/.ci/releaseBuild.yml
@@ -0,0 +1,200 @@
+# The name of the build that will be seen in mscodehub
+name: PowerShellGet-Release-$(Build.BuildId)
+
+# how is the build triggered
+# since this is a release build, no trigger as it's a manual release
+trigger: none
+
+pr:
+ branches:
+ include:
+ - master
+
+# variables to set in the build environment
+variables:
+ DOTNET_CLI_TELEMETRY_OPTOUT: 1
+ POWERSHELL_TELEMETRY_OPTOUT: 1
+
+# since this build relies on templates, we need access to those
+# This needs a service connection in the build to work
+# the *name* of the service connection must be the same as the endpoint
+resources:
+ repositories:
+ - repository: ComplianceRepo
+ type: github
+ endpoint: ComplianceGHRepo
+ name: PowerShell/compliance
+ # this can be any branch of your choosing
+ ref: master
+
+# the stages in this build. There are 2
+# the assumption for is that test is done as part of
+# CI so we needn't do it here
+stages:
+- stage: Build
+ displayName: Build
+ pool:
+ name: 1ES
+ demands:
+ - ImageOverride -equals PSMMS2019-Secure
+ jobs:
+ - job: Build_Job
+ displayName: Build Microsoft.PowerShell.PowerShellGet
+ # note the variable reference to ESRP.
+ # this must be created in Project -> Pipelines -> Library -> VariableGroups
+ # where it describes the link to the SigningServer
+ variables:
+ - group: ESRP
+ steps:
+ - checkout: self
+
+ # these are setting vso variables which will be persisted between stages
+ - pwsh: |
+ $signSrcPath = "$(Build.SourcesDirectory)/PowerShellGet/src"
+ dir
+ # Set signing src path variable
+ $vstsCommandString = "vso[task.setvariable variable=signSrcPath]${signSrcPath}"
+ Write-Host "sending " + $vstsCommandString
+ Write-Host "##$vstsCommandString"
+
+ $signOutPath = "$(Build.SourcesDirectory)/OSS_Microsoft_CompatPowerShellGet/signed/PowerShellGet"
+ $null = New-Item -ItemType Directory -Path $signOutPath
+ # Set signing out path variable
+ $vstsCommandString = "vso[task.setvariable variable=signOutPath]${signOutPath}"
+ Write-Host "sending " + $vstsCommandString
+ Write-Host "##$vstsCommandString"
+
+ # Set path variable for guardian codesign validation
+ $vstsCommandString = "vso[task.setvariable variable=GDN_CODESIGN_TARGETDIRECTORY]${signOutPath}"
+ Write-Host "sending " + $vstsCommandString
+ Write-Host "##$vstsCommandString"
+
+ # Get version and create a variable
+ $moduleData = Import-PowerShellDataFile "$(Build.SourcesDirectory)/PowerShellGet/src/PowerShellGet.psd1"
+ $moduleVersion = $moduleData.ModuleVersion
+ $vstsCommandString = "vso[task.setvariable variable=moduleVersion]${moduleVersion}"
+ Write-Host "sending " + $vstsCommandString
+ Write-Host "##$vstsCommandString"
+ displayName: Setup variables for signing
+
+ # checkout the Compliance repository so it can be used to do the actual signing
+ - checkout: ComplianceRepo
+
+ # this the MS authored step This cert covers MS authored items
+ # note that the buildOutputPath (where we get the files to sign)
+ # is the same as the signOutputPath in the previous step
+ # at the end of this step we will have all the files signed that should be
+ # signOutPath is the location which contains the files we will use to make the module
+ - template: EsrpSign.yml@ComplianceRepo
+ parameters:
+ # the folder which contains the binaries to sign
+ buildOutputPath: $(signSrcPath)
+ # the location to put the signed output
+ signOutputPath: $(signOutPath)
+ # the certificate ID to use (Authenticode)
+ certificateId: "CP-230012"
+ pattern: |
+ **\*.psd1
+ **\*.psm1
+ useMinimatch: true
+
+ - template: Sbom.yml@ComplianceRepo
+ parameters:
+ BuildDropPath: $(signOutPath)
+ Build_Repository_Uri: 'https://github.com/powershell/powershellget'
+ PackageName: 'PowerShellGet'
+ PackageVersion: '$(moduleVersion)'
+
+ - pwsh: |
+ Set-PSRepository PSGallery -InstallationPolicy Trusted
+ Install-Module "Microsoft.PowerShell.PSResourceGet" -Repository PSGallery
+ displayName: Install and import Microsoft.PowerShell.PSResourceGet
+
+ # Register local folder as PSRepository
+ # Then publish module to that folder
+ - pwsh: |
+ $localRepo = "$(Build.SourcesDirectory)/local"
+ New-Item -Path $localRepo -ItemType Directory -Force
+ $vstsCommandString = "vso[task.setvariable variable=localRepo]${localRepo}"
+ Write-Host "local repo is: " + $vstsCommandString
+ Write-Host "##$vstsCommandString"
+
+ Register-PSResourceRepository -Name local -URI $localRepo
+ Publish-PSResource -Path $(signOutPath) -Repository local
+ displayName: Publish module to local repository
+
+ # finally publish the parts of the build which will be used in the next stages
+ # if it's not published, the subsequent stages will not be able to access it.
+ - publish: "$(signOutPath)"
+ artifact: build
+ displayName: publish build directory
+
+ - pwsh: |
+ $nupkgPath = "$(localRepo)"
+ $artifactName = "PowerShellGet"
+ Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$nupkgPath"
+ displayName: Upload module artifact
+
+# Now on to the compliance stage
+- stage: Compliance
+ displayName: Compliance
+ dependsOn: Build
+ jobs:
+ - job: Compliance_Job
+ pool:
+ name: 1ES
+ demands:
+ - ImageOverride -equals PSMMS2019-Secure
+ steps:
+ - checkout: self
+ - checkout: ComplianceRepo
+
+ # use the templates in the compliance repo
+ # no assemblies, you should use script-module-compliance template
+ - template: script-module-compliance.yml@ComplianceRepo
+ parameters:
+ # component-governance - the path to sources
+ sourceScanPath: '$(Build.SourcesDirectory)/PowerShellGet'
+ # TermCheck
+ optionsRulesDBPath: ''
+ optionsFTPath: ''
+ # tsa-upload
+ # the compliance scanning must be uploaded, which you need to request
+ codeBaseName: 'CompatPowerShellGet_20200201'
+ # selections
+ APIScan: false # set to false when not using Windows APIs.
+
+- stage: Publish
+ displayName: Publish
+ dependsOn: Compliance
+ pool:
+ name: 1ES
+ demands:
+ - ImageOverride -equals PSMMS2019-Secure
+ jobs:
+ - job: Publish_Job
+ displayName: Build Microsoft.PowerShell.PowerShellGet
+ steps:
+ - checkout: self
+
+ - task: DownloadPipelineArtifact@2
+ displayName: 'Download PowerShellGet module artifacts'
+ inputs:
+ artifact: PowerShellGet
+ patterns: '**/*.nupkg'
+ downloadPath: '$(Pipeline.Workspace)/nuget'
+
+ - pwsh: |
+ $package = (Get-ChildItem '$(Pipeline.Workspace)/nuget/PowerShellGet.*.nupkg').FullName
+ $vstsCommandString = "vso[task.setvariable variable=NugetPkgPath]${package}"
+ Write-Host "sending " + $vstsCommandString
+ Write-Host "##$vstsCommandString"
+ displayName: 'Capture PowerShellGet module NuGet package path and set environment variable'
+
+ - task: NuGetCommand@2
+ displayName: 'Push PowerShellGet module artifacts to PSGallery feed'
+ inputs:
+ command: push
+ packagesToPush: '$(NugetPkgPath)'
+ nuGetFeedType: external
+ publishFeedCredentials: PSGalleryPush
diff --git a/.config/CredScanSuppressions.json b/.config/CredScanSuppressions.json
new file mode 100644
index 0000000..e6a6cfb
--- /dev/null
+++ b/.config/CredScanSuppressions.json
@@ -0,0 +1,10 @@
+{
+ "tool": "Credential Scanner",
+ "suppressions": [
+ {
+ "file": "Test/PublishPSResource.Tests.ps1",
+ "_justification": "Auto generated fake key"
+ }
+ ]
+ }
+
\ No newline at end of file
diff --git a/.config/tsaoptions.json b/.config/tsaoptions.json
new file mode 100644
index 0000000..692eaec
--- /dev/null
+++ b/.config/tsaoptions.json
@@ -0,0 +1,10 @@
+{
+ "instanceUrl": "https://msazure.visualstudio.com",
+ "projectName": "One",
+ "areaPath": "One\\MGMT\\Compute\\Powershell\\Powershell\\PowerShell Core",
+ "notificationAliases": [
+ "adityap@microsoft.com",
+ "americks@microsoft.com",
+ "annavied@microsoft.com"
+ ]
+}
diff --git a/.pipelines/PowerShellGet-Official.yml b/.pipelines/PowerShellGet-Official.yml
new file mode 100644
index 0000000..2d13f29
--- /dev/null
+++ b/.pipelines/PowerShellGet-Official.yml
@@ -0,0 +1,282 @@
+#################################################################################
+# OneBranch Pipelines #
+# This pipeline was created by EasyStart from a sample located at: #
+# https://aka.ms/obpipelines/easystart/samples #
+# Documentation: https://aka.ms/obpipelines #
+# Yaml Schema: https://aka.ms/obpipelines/yaml/schema #
+# Retail Tasks: https://aka.ms/obpipelines/tasks #
+# Support: https://aka.ms/onebranchsup #
+#################################################################################
+name: PowerShellGet-Release-$(Build.BuildId)
+trigger: none # https://aka.ms/obpipelines/triggers
+pr:
+ branches:
+ include:
+ - main
+ - release*
+parameters: # parameters are shown up in ADO UI in a build queue time
+- name: 'debug'
+ displayName: 'Enable debug output'
+ type: boolean
+ default: false
+
+variables:
+ - name: DOTNET_CLI_TELEMETRY_OPTOUT
+ value: 1
+ - name: POWERSHELL_TELEMETRY_OPTOUT
+ value: 1
+ - name: WindowsContainerImage
+ value: onebranch.azurecr.io/windows/ltsc2022/vse2022:latest # Docker image which is used to build the project https://aka.ms/obpipelines/containers
+
+resources:
+ repositories:
+ - repository: onebranchTemplates
+ type: git
+ name: OneBranch.Pipelines/GovernedTemplates
+ ref: refs/heads/main
+
+extends:
+ template: v2/OneBranch.Official.CrossPlat.yml@onebranchTemplates # https://aka.ms/obpipelines/templates
+ parameters:
+ featureFlags:
+ WindowsHostVersion: '1ESWindows2022'
+ customTags: 'ES365AIMigrationTooling'
+ globalSdl:
+ disableLegacyManifest: true
+ sbom:
+ enabled: true
+ packageName: Microsoft.PowerShell.PowerShellGet
+ codeql:
+ compiled:
+ enabled: true
+ asyncSdl: # https://aka.ms/obpipelines/asyncsdl
+ enabled: true
+ forStages: [stagebuild]
+ credscan:
+ enabled: true
+ scanFolder: $(Build.SourcesDirectory)\PowerShellGet
+ binskim:
+ enabled: true
+ apiscan:
+ enabled: false
+
+ stages:
+ - stage: stagebuild
+ displayName: Build and Package PowerShellGet
+ jobs:
+ - job: jobbuild
+ displayName: Build PowerShellGet Files
+ variables: # More settings at https://aka.ms/obpipelines/yaml/jobs
+ - name: ob_outputDirectory
+ value: '$(Build.ArtifactStagingDirectory)/ONEBRANCH_ARTIFACT'
+ - name: repoRoot
+ value: $(Build.SourcesDirectory)\PowerShellGet
+ - name: ob_sdl_tsa_configFile
+ value: $(Build.SourcesDirectory)\PowerShellGet\.config\tsaoptions.json
+ - name: signSrcPath
+ value: $(repoRoot)/out/PowerShellGet
+ - name: ob_sdl_sbom_enabled
+ value: true
+ - name: ob_signing_setup_enabled
+ value: true
+ #CodeQL tasks added manually to workaround signing failures
+ - name: ob_sdl_codeql_compiled_enabled
+ value: false
+ pool:
+ type: windows
+ steps:
+ - checkout: self
+ env:
+ ob_restore_phase: true # Set ob_restore_phase to run this step before '🔒 Setup Signing' step.
+
+ - pwsh: |
+ if (-not (Test-Path $(repoRoot)/.config/tsaoptions.json)) {
+ Get-ChildItem $(Build.SourcesDirectory) -recurse -ErrorAction SilentlyContinue
+ throw "tsaoptions.json does not exist under $(repoRoot)/.config"
+ }
+ displayName: Test if tsaoptions.json exists
+ env:
+ ob_restore_phase: true # Set ob_restore_phase to run this step before '🔒 Setup Signing' step.
+
+ - pwsh: |
+ Get-ChildItem env:
+ displayName: Capture Environment
+ env:
+ ob_restore_phase: true # Set ob_restore_phase to run this step before '🔒 Setup Signing' step.
+
+ - pwsh: |
+ Write-Host "Displaying contents of repoRoot:"
+ Get-ChildItem $(repoRoot) -Recurse
+ displayName: Get contents of repoRoot
+
+ - pwsh: |
+ New-Item -ItemType Directory -Path $(signSrcPath) -Force
+ displayName: Make signSrcPath directory
+
+ - pwsh: |
+ Get-ChildItem $(repoRoot)/src/PowerShellGet.psd1
+ Get-ChildItem $(repoRoot)/src/PowerShellGet.psm1
+
+ Copy-Item $(repoRoot)/src/PowerShellGet.psd1 $(signSrcPath)/PowerShellGet.psd1 -Verbose
+ Copy-Item $(repoRoot)/src/PowerShellGet.psm1 $(signSrcPath)/PowerShellGet.psm1 -Verbose
+ displayName: Copy files to be signed to signSrcPath
+
+ - task: onebranch.pipeline.signing@1
+ displayName: Sign 1st party files
+ inputs:
+ command: 'sign'
+ signing_profile: external_distribution
+ files_to_sign: '**\*.psd1;**\*.psm1;**\*.ps1xml'
+ search_root: $(signSrcPath)
+
+ - pwsh: |
+ Write-Host "Displaying contents of signSrcPath:"
+ Get-ChildItem $(signSrcPath) -Recurse
+ displayName: Get contents of signSrcPath
+
+ - task: CopyFiles@2
+ displayName: "Copy signed files to ob_outputDirectory - '$(ob_outputDirectory)'"
+ inputs:
+ SourceFolder: "$(signSrcPath)"
+ Contents: '**'
+ TargetFolder: $(ob_outputDirectory)
+
+ - pwsh: |
+ Write-Host "Displaying contents of signSrcPath:"
+ Get-ChildItem $(signSrcPath) -Recurse
+ Write-Host "Displaying contents of ob_outputDirectory:"
+ Get-ChildItem $(ob_outputDirectory) -Recurse
+ displayName: Get contents of dirs with signed files
+
+ - job: nupkg
+ dependsOn: jobbuild
+ displayName: Package PowerShellGet
+ variables:
+ - name: ob_outputDirectory
+ value: '$(Build.ArtifactStagingDirectory)/ONEBRANCH_ARTIFACT'
+ - name: repoRoot
+ value: $(Build.SourcesDirectory)\PowerShellGet
+ - name: ob_sdl_tsa_configFile
+ value: $(Build.SourcesDirectory)\PowerShellGet\.config\tsaoptions.json
+ # Disable because SBOM was already built in the previous job
+ - name: ob_sdl_sbom_enabled
+ value: false
+ - name: signOutPath
+ value: $(repoRoot)/signed
+ - name: signedModuleRoot
+ value: $(signOutPath)/PowerShellGet
+ - name: signedNupkgPath
+ value: $(signOutPath)/PublishedNupkg
+ - name: ob_signing_setup_enabled
+ value: true
+ # This job is not compiling code, so disable codeQL
+ - name: ob_sdl_codeql_compiled_enabled
+ value: false
+
+ pool:
+ type: windows
+ steps:
+ - checkout: self
+
+ - pwsh: |
+ if (-not (Test-Path $(repoRoot)/.config/tsaoptions.json)) {
+ Get-ChildItem $(Build.SourcesDirectory) -recurse -ErrorAction SilentlyContinue
+ throw "tsaoptions.json does not exist under $(repoRoot)/.config"
+ }
+ displayName: Test if tsaoptions.json exists
+
+ - task: DownloadPipelineArtifact@2
+ displayName: 'Download build files'
+ inputs:
+ targetPath: $(signedModuleRoot)
+ artifact: drop_stagebuild_jobbuild
+
+ - pwsh: |
+ Set-Location "$(signedModuleRoot)"
+ Write-Host "Contents of signedModuleRoot:"
+ Get-ChildItem $(signedModuleRoot) -Recurse
+ displayName: Capture artifacts directory structure
+
+ - pwsh: |
+ $module = 'Microsoft.PowerShell.PSResourceGet'
+ Write-Verbose "installing $module..." -verbose
+ $ProgressPreference = 'SilentlyContinue'
+ Install-Module $module -AllowClobber -Force
+ displayName: Install PSResourceGet 0.9.0 or above for build.psm1
+
+ - pwsh: |
+ Set-Location "$(signOutPath)"
+ New-Item -ItemType Directory -Path "$(signedNupkgPath)" -Force
+ Register-PSResourceRepository -Name 'localRepo' -Uri "$(signedNupkgPath)"
+ Publish-PSResource -Path "$(signedModuleRoot)" -Repository 'localRepo' -Verbose
+ displayName: Create nupkg for publishing
+
+ - task: onebranch.pipeline.signing@1
+ displayName: Sign nupkg
+ inputs:
+ command: 'sign'
+ signing_profile: external_distribution
+ files_to_sign: '**\*.nupkg'
+ search_root: "$(signedNupkgPath)"
+
+ - pwsh: |
+ Set-Location "$(signedNupkgPath)"
+ Write-Host "Contents of signedNupkgPath:"
+ Get-ChildItem "$(signedNupkgPath)" -Recurse
+ displayName: Find Nupkg
+
+ - task: CopyFiles@2
+ displayName: "Copy nupkg to ob_outputDirectory - '$(ob_outputDirectory)'"
+ inputs:
+ Contents: $(signedNupkgPath)\PowerShellGet.*.nupkg
+ TargetFolder: $(ob_outputDirectory)
+
+ - pwsh: |
+ Write-Host "Contents of ob_outputDirectory:"
+ Get-ChildItem "$(ob_outputDirectory)" -Recurse
+ displayName: Find Signed Nupkg
+
+ - stage: release
+ displayName: Release PowerShellGet
+ dependsOn: stagebuild
+ variables:
+ version: $[ stageDependencies.build.main.outputs['package.version'] ]
+ drop: $(Pipeline.Workspace)/drop_build_main
+ jobs:
+ - job: validation
+ displayName: Manual validation
+ pool:
+ type: agentless
+ timeoutInMinutes: 1440
+ steps:
+ - task: ManualValidation@0
+ displayName: Wait 24 hours for validation
+ inputs:
+ instructions: Please validate the release
+ timeoutInMinutes: 1440
+ - job: PSGalleryPublish
+ displayName: Publish to PSGallery
+ dependsOn: validation
+ pool:
+ type: windows
+ variables:
+ ob_outputDirectory: '$(Build.ArtifactStagingDirectory)/ONEBRANCH_ARTIFACT'
+ steps:
+ - download: current
+ displayName: Download artifact
+
+ - pwsh: |
+ Get-ChildItem $(Pipeline.Workspace) -Recurse
+ displayName: Capture environment
+
+ - pwsh: |
+ Get-ChildItem "$(Pipeline.Workspace)/drop_stagebuild_nupkg" -Recurse
+ displayName: Find signed Nupkg
+
+ - task: NuGetCommand@2
+ displayName: Push PowerShellGet module artifacts to PSGallery feed
+ inputs:
+ command: push
+ packagesToPush: '$(Pipeline.Workspace)\drop_stagebuild_nupkg\PowerShellGet\signed\PublishedNupkg\PowerShellGet.*.nupkg'
+ nuGetFeedType: external
+ publishFeedCredentials: PSGet-PSGalleryPush
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dd89f7a..4c26ede 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,23 @@
# Changelog
+### 3.0.23-beta23
+* Changes
+- Add internal hook for PSResourceGet telemetry
+
+### 3.0.22-beta22
+* Changes
+- This module was renamed from 'CompatPowerShellGet' to 'PowerShellGet'
+
+### 0.0.4
+* Changes
+- Update module to be compatible with latest version of PowerShellGet (3.0.21-beta21)
+
+### 0.0.3
+* Changes
+- Updated reference to PowerShellGet 'Url' parameter to 'Uri' to reflect changes made in PowerShellGet
+
+### 0.0.2
+* Bug Fix
+- Remove -Force parameter when calling into v3 cmdlets
+
### 0.0.1
* Initial release
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
index 638de68..8312fc6 100644
--- a/CODE_OF_CONDUCT.md
+++ b/CODE_OF_CONDUCT.md
@@ -1,8 +1,10 @@
-# Code of Conduct
+# Microsoft Open Source Code of Conduct
-This project has adopted the [Microsoft Open Source Code of Conduct][conduct-code].
-For more information see the [Code of Conduct FAQ][conduct-FAQ] or contact [opencode@microsoft.com][conduct-email] with any additional questions or comments.
+This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
-[conduct-code]: https://opensource.microsoft.com/codeofconduct/
-[conduct-FAQ]: https://opensource.microsoft.com/codeofconduct/faq/
-[conduct-email]: mailto:opencode@microsoft.com
\ No newline at end of file
+Resources:
+
+- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
+- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
+- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns
+- Employees can reach out at [aka.ms/opensource/moderation-support](https://aka.ms/opensource/moderation-support)
diff --git a/README.md b/README.md
index ca36afb..e973a52 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,12 @@
-# PowerShellGetCompat
+# PowerShellGet
-[](https://www.powershellgallery.com/packages/PowerShellGetCompat)
-[](https://github.com/PowerShell/PowerShellGetCompat)
+[](https://www.powershellgallery.com/packages/PowerShellGet)
+[](https://github.com/PowerShell/PowerShellGet)
Introduction
============
-PowerShellGetCompat is a compatibility module that allows use of PowerShellGet 2.x (and below) cmdlet syntax with PowerShellGet 3.0 (and newer) functionality by making a best effort mapping between the cmdlet interfaces of both versions of the module.'
+PowerShellGet v3 is a compatibility module that allows use of PowerShellGet 2.x (and below) cmdlet syntax with PSResourceGet functionality by making a best effort mapping between the cmdlet interfaces of both versions of the module.'
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
@@ -16,21 +16,21 @@ questions or comments.
Documentation
=============
-Documentation for PowerShellGetCompat has not yet been published, please
+Documentation for PowerShellGet has not yet been published, please
[Click here](https://docs.microsoft.com/powershell/module/PowerShellGet/?view=powershell-7)
to reference the documentation for previous versions of PowerShellGet.
Requirements
============
-- Windows PowerShell 3.0 or newer.
+- Windows PowerShell 5.1 or newer.
- PowerShell Core.
-Get PowerShellGetCompat Module
+Get PowerShellGet Module
========================
-Please refer to our [documentation](https://www.powershellgallery.com/packages/PowerShellGetCompat/) for the up-to-date version on how to get the PowerShellGetCompat Module.
+Please refer to our [documentation](https://www.powershellgallery.com/packages/PowerShellGet/) for the up-to-date version on how to get the PowerShellGet Module.
Get PowerShellGet Source
@@ -38,17 +38,27 @@ Get PowerShellGet Source
#### Steps
* Obtain the source
- - Download the latest source code from the release page (https://github.com/PowerShell/PowerShellGetCompat/releases) OR
+ - Download the latest source code from the release page (https://github.com/PowerShell/PowerShellGet/releases) OR
- Clone the repository (needs git)
```powershell
- git clone https://github.com/PowerShell/PowerShellGetCompat
+ git clone https://github.com/PowerShell/PowerShellGet
```
* Navigate to the source directory
```powershell
-cd path/to/PowerShellGetCompat
+cd path/to/PowerShellGet
```
* Import the module
```powershell
-Import-Module src/PowerShellGetCompat
+Import-Module src/PowerShellGet -Force
```
+
+Code of Conduct
+===============
+
+Please see our [Code of Conduct](CODE_OF_CONDUCT.md) before participating in this project.
+
+Security Policy
+===============
+
+For any security issues, please see our [Security Policy](SECURITY.md).
diff --git a/SECURITY.md b/SECURITY.md
new file mode 100644
index 0000000..f941d30
--- /dev/null
+++ b/SECURITY.md
@@ -0,0 +1,41 @@
+
+
+## Security
+
+Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin) and [PowerShell](https://github.com/PowerShell).
+
+If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/security.md/definition), please report it to us as described below.
+
+## Reporting Security Issues
+
+**Please do not report security vulnerabilities through public GitHub issues.**
+
+Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/security.md/msrc/create-report).
+
+If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/security.md/msrc/pgp).
+
+You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
+
+Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
+
+ * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
+ * Full paths of source file(s) related to the manifestation of the issue
+ * The location of the affected source code (tag/branch/commit or direct URL)
+ * Any special configuration required to reproduce the issue
+ * Step-by-step instructions to reproduce the issue
+ * Proof-of-concept or exploit code (if possible)
+ * Impact of the issue, including how an attacker might exploit the issue
+
+This information will help us triage your report more quickly.
+
+If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/security.md/msrc/bounty) page for more details about our active programs.
+
+## Preferred Languages
+
+We prefer all communications to be in English.
+
+## Policy
+
+Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd).
+
+
diff --git a/SignConfig.xml b/SignConfig.xml
index fae5332..64d42f8 100644
--- a/SignConfig.xml
+++ b/SignConfig.xml
@@ -3,8 +3,8 @@
-
-
-
+
+
+
diff --git a/Test/FindPSResource.Tests.ps1 b/Test/FindPSResource.Tests.ps1
new file mode 100644
index 0000000..066dc68
--- /dev/null
+++ b/Test/FindPSResource.Tests.ps1
@@ -0,0 +1,207 @@
+# Copyright (c) Microsoft Corporation.
+# Licensed under the MIT License.
+
+$modPath = "$psscriptroot/../PSGetTestUtils.psm1"
+Import-Module $modPath -Force -Verbose
+Write-Verbose -Verbose -Message "PowerShellGet version currently loaded: $($(Get-Module powershellget).Version)"
+
+Describe 'Test CompatPowerShellGet: Find-PSResource' -tags 'CI' {
+
+ BeforeAll{
+ $PSGalleryName = Get-PSGalleryName
+ $testModuleName = "test_module"
+ $testScriptName = "test_script"
+ $testModuleName2 = "testmodule99"
+ $commandName = "Get-TargetResource"
+ $dscResourceName = "SystemLocale"
+ $parentModuleName = "SystemLocaleDsc"
+ Get-NewPSResourceRepositoryFile
+ }
+
+ AfterAll {
+ Get-RevertPSResourceRepositoryFile
+ }
+
+ It "Find-Module without any parameter values" {
+ $psgetItemInfo = Find-Module -Repository PSGallery
+ $psgetItemInfo.Count | Should -BeGreaterOrEqual 1
+ }
+
+ It "Find a specific module" {
+ $res = Find-Module "testModule99" -Repository PSGallery
+ $res | Should -Not -BeNullOrEmpty
+ $res.Name | Should -Be "testModule99"
+ }
+
+ It "Find-Module with range wildcards" {
+ $res = Find-Module -Name "TestModule9*" -Repository PSGallery
+ $res | Should -Not -BeNullOrEmpty
+ $res.Name | Should -Be "TestModule99"
+ }
+
+ It "Find not available module with wildcards" {
+ $res = Find-Module -Name "TestModule5test*" -Repository PSGallery
+ $res | Should -BeNullOrEmpty
+ }
+
+ It "Find-Module with min version" {
+ $res = Find-Module TestModule99 -MinimumVersion 0.0.3 -Repository PSGallery
+ $res.Name | Should -Contain "TestModule99"
+ $res | ForEach-Object { $_.Version | Should -BeGreaterOrEqual ([System.Version]"0.0.3") }
+ }
+
+ It "Find-Module with min version not available" {
+ $res = Find-Module TestModule99 -MinimumVersion 10.0 -Repository PSGallery
+ $res | Should -BeNullOrEmpty
+ }
+
+ It "Find-Module with required version not available" {
+ $res = Find-Module TestModule99 -RequiredVersion 12.0 -Repository PSGallery -ErrorVariable ev -ErrorAction SilentlyContinue
+ $res | Should -BeNullOrEmpty
+ }
+
+ It "Find-Module with required version" {
+ $res = Find-Module TestModule99 -RequiredVersion 0.0.2 -Repository PSGallery
+ $res | Should -Not -BeNullOrEmpty
+ $res.Name | Should -Be "TestModule99"
+ $res.Version | Should -Be ([System.Version]"0.0.2")
+ }
+
+ It "Find-Module with multiple module names and required version" {
+ $res = Find-Module TestModuleWithDependencyB, TestModuleWithDependencyC -RequiredVersion 3.0 -Repository PSGallery
+ $res | Should -HaveCount 2
+ $res | ForEach-Object { $_.Version | Should -Be ([System.Version]"3.0") }
+ }
+
+ It "Find-Module with module name and minimum version" {
+ $res = Find-Module TestModule99 -MinimumVersion 0.5 -Repository PSGallery
+ $res | Should -HaveCount 0
+ }
+
+ It "Find-Module with multiple module names and minimum version" {
+ $res = Find-Module TestModule99, TestModuleWithDependencyB -MinimumVersion 0.5 -Repository PSGallery
+ $res | Should -HaveCount 2
+ $res.Name | Should -Not -Contain "TestModule99"
+ $res | ForEach-Object { $_.Version | Should -BeGreaterOrEqual ([System.Version]"0.5") }
+ }
+
+ It "Find-Module with wildcard name and minimum version" {
+ $res = Find-Module TestModule9* -MinimumVersion 0.0.3 -Repository PSGallery -ErrorAction SilentlyContinue -ErrorVariable err
+ $err | Should -Not -BeNullOrEmpty
+ $res | Should -BeNullOrEmpty
+ }
+
+ It "Find-Module with multinames" {
+ $res = Find-Module TestModuleWithDependencyB, TestModuleWithDependencyC, TestModuleWithDependencyD -Repository PSGallery
+ $res | Should -HaveCount 3
+ }
+
+ It "Find-Module with all versions" {
+ $res = Find-Module TestModule99 -Repository PSGallery -AllVersions
+ $res.Count | Should -BeGreaterThan 1
+ }
+
+ It "Find-DscResource with single resource name" {
+ $res = Find-DscResource -Name SystemLocale -Repository $PSGalleryName
+ Foreach ($dscresource in $res) {
+ $dscresource.Names | Should -Be "SystemLocale"
+ $dscresource.ParentResource | Should -Be ("ComputerManagementDsc" -or "SystemLocaleDsc")
+ }
+ }
+
+ It "Find-DscResource with two resource names" {
+ $res = Find-DscResource -Name "SystemLocale", "MSFT_PackageManagement" -Repository $PSGalleryName
+ Foreach ($dscresource in $res) {
+ $dscresource.Names | Should -Be ("SystemLocale" -or "MSFT_PackageManagement")
+ $dscresource.ParentResource | Should -Be ("ComputerManagementDsc" -or "SystemLocaleDsc" -or "PackageManagement")
+ }
+ }
+
+ It "Find-Command with single command name" {
+ $res = Find-Command -Name $commandName -Repository $PSGalleryName
+ $res | ForEach-Object { $_.Names | Should -Be $commandName }
+ }
+
+ It "Find-Module with IncludeDependencies" {
+ $ModuleName = "TestModuleWithDependencyE"
+
+ $res = Find-Module -Name $ModuleName -IncludeDependencies
+ $res.Count | Should -BeGreaterOrEqual 2
+ }
+
+ It "find module given specific Name, Version null" {
+ $res = Find-Module -Name $testModuleName2 -Repository $PSGalleryName
+ $res.Name | Should -Be $testModuleName2
+ $res.Version | Should -Be "0.0.93"
+ }
+
+ It "should not find module given nonexistant Name" {
+ $res = Find-Module -Name NonExistantModule -Repository $PSGalleryName -ErrorVariable err -ErrorAction SilentlyContinue
+ $res | Should -BeNullOrEmpty
+ $err.Count | Should -BeGreaterThan 0
+ $err[0].FullyQualifiedErrorId | Should -BeExactly "FindNameResponseConversionFail,Microsoft.PowerShell.PowerShellGet.Cmdlets.FindPSResource"
+ $res | Should -BeNullOrEmpty
+ }
+
+ It "find script(s) given wildcard Name" {
+ $foundScript = $False
+ $res = Find-Script -Name "test_scri*" -Repository $PSGalleryName
+ $res | Should -HaveCount 1
+ foreach ($item in $res)
+ {
+ if ($item.Type -eq "Script")
+ {
+ $foundScript = $true
+ }
+ }
+
+ $foundScript | Should -BeTrue
+ }
+
+ It "find all versions of module when given specific Name, Version not null --> '*'" {
+ $res = Find-Module -Name $testModuleName2 -AllVersions -Repository $PSGalleryName
+ $res | ForEach-Object {
+ $_.Name | Should -Be $testModuleName2
+ }
+
+ $res.Count | Should -BeGreaterThan 1
+ }
+
+ It "find module with latest (including prerelease) version given Prerelease parameter" {
+ # test_module resource's latest version is a prerelease version, before that it has a non-prerelease version
+ $res = Find-Module -Name $testModuleName2 -Repository $PSGalleryName
+ $res.Version | Should -Be "0.0.93"
+
+ $resPrerelease = Find-Module -Name $testModuleName2 -AllowPrerelease -Repository $PSGalleryName
+ $resPrerelease.Version | Should -Be "1.0.0"
+ $resPrerelease.Prerelease | Should -Be "beta2"
+ }
+
+ It "find script from PSGallery" {
+ $resScript = Find-Script -Name $testScriptName -Repository $PSGalleryName
+ $resScript.Name | Should -Be $testScriptName
+ $resScriptType = Out-String -InputObject $resScript.Type
+ $resScriptType.Replace(",", " ").Split() | Should -Contain "Script"
+ }
+
+ It "find module from PSGallery" {
+ $resModule = Find-Module -Name $testModuleName -Repository $PSGalleryName
+ $resModule.Name | Should -Be $testModuleName
+ $resModuleType = Out-String -InputObject $resModule.Type
+ $resModuleType.Replace(",", " ").Split() | Should -Contain "Module"
+ }
+
+ It "Find-RoleCapability should emit warning" {
+ $results = Find-RoleCapability -Name $testModuleName -Repository $PSGalleryName -WarningVariable wv
+ $results | Should -BeNullOrEmpty
+ $wv[0] | Should -Be "The cmdlet 'Find-RoleCapability' is deprecated."
+ }
+}
+
+# Ensure that PSGet v2 was not loaded during the test via command discovery
+$PSGetVersionsLoaded = (Get-Module powershellget).Version
+Write-Host "PowerShellGet versions currently loaded: $PSGetVersionsLoaded"
+if ($PSGetVersionsLoaded.Count -gt 1) {
+ throw "There was more than one version of PowerShellGet imported into the current session. `
+ Imported versions include: $PSGetVersionsLoaded"
+}
\ No newline at end of file
diff --git a/Test/GetInstalledPSResource.Tests.ps1 b/Test/GetInstalledPSResource.Tests.ps1
new file mode 100644
index 0000000..c627626
--- /dev/null
+++ b/Test/GetInstalledPSResource.Tests.ps1
@@ -0,0 +1,141 @@
+# Copyright (c) Microsoft Corporation.
+# Licensed under the MIT License.
+
+$ProgressPreference = "SilentlyContinue"
+$modPath = "$psscriptroot/../PSGetTestUtils.psm1"
+Import-Module $modPath -Force -Verbose
+Write-Verbose -Verbose -Message "PowerShellGet version currently loaded: $($(Get-Module powershellget).Version)"
+
+Describe 'Test CompatPowerShellGet: Get-InstalledPSResource' -tags 'CI' {
+
+ BeforeAll{
+ $PSGalleryName = Get-PSGalleryName
+ $testModuleName = "testmodule99"
+ $testScriptName = "test_script"
+ Get-NewPSResourceRepositoryFile
+ Set-PSResourceRepository PSGallery -Trusted
+
+ Install-PSResource -Name $testModuleName -Repository $PSGalleryName
+ Install-PSResource -Name $testModuleName -Repository $PSGalleryName -Version "0.0.1"
+ Install-PSResource -Name $testModuleName -Repository $PSGalleryName -Version "0.0.2"
+ Install-PSResource -Name $testModuleName -Repository $PSGalleryName -Version "0.0.3"
+ Install-PSResource -Name $testScriptName -Repository $PSGalleryName -SkipDependencyCheck
+ }
+
+ AfterAll {
+ Uninstall-PSResource -Name $testModuleName -Version "*" -ErrorAction SilentlyContinue
+ Uninstall-PSResource -Name $testScriptName -Version "*" -ErrorAction SilentlyContinue
+ Get-RevertPSResourceRepositoryFile
+ }
+
+ It "Get-InstalledModule with MinimumVersion available" {
+ $res = Get-InstalledModule -Name $testModuleName -MinimumVersion "0.0.1"
+ $res.Count | Should -BeGreaterThan 1
+ foreach ($pkg in $res)
+ {
+ $pkg.Version | Should -BeGreaterOrEqual ([System.Version] "0.0.1")
+ }
+ }
+
+ It "Get-InstalledScript with MinimumVersion available" {
+ $res = Get-InstalledScript -Name $testScriptName -MinimumVersion "1.0.0"
+ $res.Count | Should -BeGreaterOrEqual 1
+ foreach ($pkg in $res)
+ {
+ $pkg.Version | Should -BeGreaterOrEqual ([System.Version] "1.0.0")
+ }
+ }
+
+ It "Get-InstalledModule with MinimumVersion not available" {
+ $res = Get-InstalledModule -Name $testModuleName -MinimumVersion "1.0.0"
+ $res | Should -HaveCount 0
+ }
+
+ It "Get-InstalledModule with min/max range" {
+ $res = Get-InstalledModule -Name $testModuleName -MinimumVersion "0.0.15" -MaximumVersion "0.0.25"
+ foreach ($pkg in $res)
+ {
+ $pkg.Version | Should -BeGreaterOrEqual ([System.Version] "0.0.2")
+ }
+ }
+
+ It "Get-InstalledModule with -RequiredVersion" {
+ $version = "0.0.2"
+ $res = Get-InstalledModule -Name $testModuleName -RequiredVersion $version
+ $res.Version | Should -Be $version
+ }
+
+ It "Get prerelease version module when version with correct prerelease label is specified" {
+ Install-PSResource -Name $testModuleName -Version "1.0.0-beta2" -Repository $PSGalleryName
+ $res = Get-InstalledModule -Name $testModuleName -RequiredVersion "1.0.0"
+ $res | Should -BeNullOrEmpty
+ $res = Get-InstalledModule -Name $testModuleName -RequiredVersion "1.0.0-beta2"
+ $res.Name | Should -Be $testModuleName
+ $res.Version | Should -Be "1.0.0"
+ $res.Prerelease | Should -Be "beta2"
+ }
+
+ It "Get prerelease version script when version with correct prerelease label is specified" {
+ Install-PSResource -Name $testScriptName -Version "3.0.0-alpha" -Repository $PSGalleryName -TrustRepository
+ $res = Get-InstalledScript -Name $testScriptName -RequiredVersion "3.0.0"
+ $res | Should -BeNullOrEmpty
+ $res = Get-InstalledScript -Name $testScriptName -RequiredVersion "3.0.0-alpha"
+ $res.Name | Should -Be $testScriptName
+ $res.Version | Should -Be "3.0.0"
+ $res.Prerelease | Should -Be "alpha"
+ }
+
+ It "Get-InstalledModule with Wildcard" {
+ $module = Get-InstalledModule -Name "testmodule9*"
+ $module.Count | Should -BeGreaterOrEqual 3
+ }
+
+ It "Get-InstalledModule with Wildcard" {
+ $module = Get-InstalledScript -Name "test_scri*"
+ $module.Count | Should -BeGreaterOrEqual 1
+ }
+
+ It "Get modules without any parameter values" {
+ $pkgs = Get-InstalledScript
+ $pkgs.Count | Should -BeGreaterThan 1
+ }
+
+ It "Get scripts without any parameter values" {
+ $pkgs = Get-InstalledModule
+ $pkgs.Count | Should -BeGreaterThan 1
+ }
+
+ It "Get specific module resource by name" {
+ $pkg = Get-InstalledModule -Name $testModuleName
+ $pkg.Name | Should -Contain $testModuleName
+ }
+
+ It "Get specific script resource by name" {
+ $pkg = Get-InstalledScript -Name $testScriptName
+ $pkg.Name | Should -Be $testScriptName
+ }
+
+ It "Get resource when given Name to " {
+ $pkgs = Get-InstalledModule -Name "*estmodul*"
+ $pkgs.Name | Should -Contain $testModuleName
+ }
+
+ It "Get resource when given Name to " -TestCases @(
+ @{Name="*estmodul*"; Reason="validate name, with wildcard at beginning and end of name: *estmodul*"},
+ @{Name="testmod*"; Reason="validate name, with wildcard at end of name: testmod*"},
+ @{Name="*estmodule99"; Reason="validate name, with wildcard at beginning of name: *estmodule99"},
+ @{Name="tes*ule99"; Reason="validate name, with wildcard in middle of name: tes*ule99"}
+ ) {
+ param($Name)
+ $pkgs = Get-InstalledModule -Name $Name
+ $pkgs.Name | Should -Contain $testModuleName
+ }
+}
+
+# Ensure that PSGet v2 was not loaded during the test via command discovery
+$PSGetVersionsLoaded = (Get-Module powershellget).Version
+Write-Host "PowerShellGet versions currently loaded: $PSGetVersionsLoaded"
+if ($PSGetVersionsLoaded.Count -gt 1) {
+ throw "There was more than one version of PowerShellGet imported into the current session. `
+ Imported versions include: $PSGetVersionsLoaded"
+}
\ No newline at end of file
diff --git a/Test/GetPSResourceRepository.Tests.ps1 b/Test/GetPSResourceRepository.Tests.ps1
new file mode 100644
index 0000000..ead4981
--- /dev/null
+++ b/Test/GetPSResourceRepository.Tests.ps1
@@ -0,0 +1,125 @@
+# Copyright (c) Microsoft Corporation.
+# Licensed under the MIT License.
+
+$modPath = "$psscriptroot/../PSGetTestUtils.psm1"
+Import-Module $modPath -Force -Verbose
+Write-Verbose -Verbose -Message "PowerShellGet version currently loaded: $($(Get-Module powershellget).Version)"
+
+Describe "Test CompatPowerShellGet: Get-PSResourceRepository" -tags 'CI' {
+ BeforeEach {
+ $TestRepoName1 = "testRepository"
+ $TestRepoName2 = "testRepository2"
+ $TestRepoName3 = "testRepository3"
+ Get-NewPSResourceRepositoryFile
+ $tmpDir1Path = Join-Path -Path $TestDrive -ChildPath "tmpDir1"
+ $tmpDir2Path = Join-Path -Path $TestDrive -ChildPath "tmpDir2"
+ $tmpDir3Path = Join-Path -Path $TestDrive -ChildPath "tmpDir3"
+ $tmpDirPaths = @($tmpDir1Path, $tmpDir2Path, $tmpDir3Path)
+ Get-NewTestDirs($tmpDirPaths)
+ }
+ AfterEach {
+ Get-RevertPSResourceRepositoryFile
+ $tmpDir1Path = Join-Path -Path $TestDrive -ChildPath "tmpDir1"
+ $tmpDir2Path = Join-Path -Path $TestDrive -ChildPath "tmpDir2"
+ $tmpDir3Path = Join-Path -Path $TestDrive -ChildPath "tmpDir3"
+ $tmpDirPaths = @($tmpDir1Path, $tmpDir2Path, $tmpDir3Path)
+ Get-RemoveTestDirs($tmpDirPaths)
+ }
+
+ It "get single already registered repo" {
+ Register-PSResourceRepository -Name $TestRepoName1 -Uri $tmpDir1Path
+ $res = Get-PSRepository -Name $TestRepoName1
+ $res | Should -Not -BeNullOrEmpty
+ $res.Name | Should -Be $TestRepoName1
+ }
+
+ It "get all repositories matching single wildcard name" {
+ Register-PSResourceRepository -Name $TestRepoName1 -Uri $tmpDir1Path
+ Register-PSResourceRepository -Name $TestRepoName2 -Uri $tmpDir2Path
+ Register-PSResourceRepository -Name $TestRepoName3 -Uri $tmpDir3Path
+ $res = Get-PSRepository -Name "testReposit*"
+ foreach ($entry in $res) {
+ $entry.Name | Should -Match "testReposit"
+ }
+ }
+
+ It "get all repositories matching multiple wildcard names" {
+ Register-PSResourceRepository -Name $TestRepoName1 -Uri $tmpDir1Path
+ Register-PSResourceRepository -Name $TestRepoName2 -Uri $tmpDir2Path
+ Register-PSResourceRepository -Name "MyGallery" -Uri $tmpDir3Path
+
+ $res = Get-PSRepository -Name "testReposit*","*Gallery"
+ foreach ($entry in $res) {
+ $entry.Name | Should -Match "testReposit|Gallery"
+ }
+ }
+ It "get all repositories matching multiple valid names provided" {
+ Register-PSResourceRepository -Name $TestRepoName1 -Uri $tmpDir1Path
+ Register-PSResourceRepository -Name "MyGallery" -Uri $tmpDir2Path
+
+ $res = Get-PSRepository -Name $TestRepoName1,"MyGallery"
+ foreach ($entry in $res) {
+ $entry.Name | Should -BeIn $TestRepoName1,"MyGallery"
+ }
+ }
+
+ It "not get repository that hasn't been registered/invalid name" {
+ $nonRegisteredRepoName = "nonRegisteredRepository"
+ $res = Get-PSRepository -Name $nonRegisteredRepoName -ErrorVariable err -ErrorAction SilentlyContinue
+ $res | Should -BeNullOrEmpty
+ $err.Count | Should -BeGreaterThan 0
+ $err[0].FullyQualifiedErrorId | Should -BeExactly "ErrorGettingSpecifiedRepo,Microsoft.PowerShell.PowerShellGet.Cmdlets.GetPSResourceRepository"
+ }
+
+ It "given invalid and valid Names, get valid ones and write error for non valid ones" {
+ $nonRegisteredRepoName = "nonRegisteredRepository"
+
+ Register-PSResourceRepository -Name $TestRepoName1 -Uri $tmpDir1Path
+ Register-PSResourceRepository -Name $TestRepoName2 -Uri $tmpDir2Path
+
+ $res = Get-PSRepository -Name $TestRepoName1,$nonRegisteredRepoName,$TestRepoName2 -ErrorVariable err -ErrorAction SilentlyContinue
+ $err.Count | Should -BeGreaterThan 0
+ $err[0].FullyQualifiedErrorId | Should -BeExactly "ErrorGettingSpecifiedRepo,Microsoft.PowerShell.PowerShellGet.Cmdlets.GetPSResourceRepository"
+
+ # should have successfully got the other valid/registered repositories with no error
+ foreach ($entry in $res) {
+ $entry.Name | Should -BeIn $TestRepoName1,$TestRepoName2
+ }
+ }
+
+ It "given invalid and valid CredentialInfo, get valid ones and write error for non valid ones" {
+ Get-NewPSResourceRepositoryFileWithCredentialInfo
+
+ $res = Get-PSRepository -Name "localtestrepo*" -ErrorVariable err -ErrorAction SilentlyContinue
+ $err.Count | Should -BeGreaterThan 0
+ $err[0].FullyQualifiedErrorId | Should -BeExactly "ErrorGettingSpecifiedRepo,Microsoft.PowerShell.PowerShellGet.Cmdlets.GetPSResourceRepository"
+
+ # should have successfully got the other valid/registered repositories with no error
+ foreach ($entry in $res) {
+ $entry.Name | Should -BeIn "localtestrepo1","localtestrepo2"
+ }
+ }
+
+ It "throw error and get no repositories when provided null Name" {
+ # $errorMsg = "Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again."
+ {Get-PSRepository -Name $null -ErrorAction Stop} | Should -Throw -ErrorId "ParameterArgumentValidationError,Get-PSRepository"
+ }
+
+ It "throw error and get no repositories when provided empty string Name" {
+ # $errorMsg = "Cannot validate argument on parameter 'Name'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again."
+ {Get-PSRepository -Name "" -ErrorAction Stop} | Should -Throw -ErrorId "ParameterArgumentValidationError,Get-PSRepository"
+ }
+
+ It "find all repositories if no Name provided" {
+ $res = Get-PSRepository
+ $res.Count | Should -BeGreaterThan 0
+ }
+}
+
+# Ensure that PSGet v2 was not loaded during the test via command discovery
+$PSGetVersionsLoaded = (Get-Module powershellget).Version
+Write-Host "PowerShellGet versions currently loaded: $PSGetVersionsLoaded"
+if ($PSGetVersionsLoaded.Count -gt 1) {
+ throw "There was more than one version of PowerShellGet imported into the current session. `
+ Imported versions include: $PSGetVersionsLoaded"
+}
\ No newline at end of file
diff --git a/Test/InstallPSResource.Tests.ps1 b/Test/InstallPSResource.Tests.ps1
new file mode 100644
index 0000000..1fdad79
--- /dev/null
+++ b/Test/InstallPSResource.Tests.ps1
@@ -0,0 +1,406 @@
+# Copyright (c) Microsoft Corporation.
+# Licensed under the MIT License.
+
+$ProgressPreference = "SilentlyContinue"
+$modPath = "$psscriptroot/../PSGetTestUtils.psm1"
+Import-Module $modPath -Force -Verbose
+Write-Verbose -Verbose -Message "PowerShellGet version currently loaded: $($(Get-Module powershellget).Version)"
+
+Describe 'Test CompatPowerShellGet: Install-PSResource' -tags 'CI' {
+
+ BeforeAll {
+ $PSGalleryName = Get-PSGalleryName
+ $PSGalleryUri = Get-PSGalleryLocation
+ $NuGetGalleryName = Get-NuGetGalleryName
+ $testModuleName = "test_module"
+ $testModuleName2 = "TestModule99"
+ $testScriptName = "test_script"
+ $RequiredResourceJSONFileName = "TestRequiredResourceFile.json"
+ $RequiredResourcePSD1FileName = "TestRequiredResourceFile.psd1"
+ Get-NewPSResourceRepositoryFile
+ Register-LocalRepos
+
+ Set-PSResourceRepository -Name PSGallery -Trusted
+ Unregister-PSResourceRepository -Name "psgettestlocal"
+ }
+
+ AfterEach {
+ Uninstall-PSResource "test_module", "TestModule99", "TestModuleWithDependencyB", "TestModuleWithDependencyC","TestModuleWithDependencyD", "TestModuleWithDependencyF", `
+ "newTestModule", "test_script", "RequiredModule1", "RequiredModule2", "RequiredModule3", "RequiredModule4", "RequiredModule5" -SkipDependencyCheck -ErrorAction SilentlyContinue -Version "*"
+ }
+
+ AfterAll {
+ Get-RevertPSResourceRepositoryFile
+ }
+
+ It "Install-Module testmodule99 should return" {
+ Install-Module -Name $testModuleName2 -Repository PSGallery
+
+ $res = Get-InstalledPSResource -Name $testModuleName2
+ $res.Name | Should be $testModuleName2
+ }
+
+ It "Install-Module testmodule99 -PassThru should return output" {
+ Install-Module -Name $testModuleName2 -Repository PSGallery -PassThru
+
+ $res = Get-InstalledPSResource -Name $testModuleName2
+ $res.Name | Should be $testModuleName2
+ }
+
+ It "Install-Module should not install with wildcard" {
+ Install-Module -Name "testmodule9*" -Repository PSGallery -ErrorAction SilentlyContinue
+
+ $res = Get-InstalledPSResource -Name $testModuleName2
+ $res | Should -HaveCount 0
+ }
+
+ It "Install-Module with version params" {
+ Install-Module $testModuleName2 -MinimumVersion 0.0.1 -MaximumVersion 0.0.9 -Repository PSGallery
+
+ $res = Get-InstalledPSResource -Name $testModuleName2
+ $res.Name | Should be $testModuleName2
+ $res.Version | Should be "0.0.9"
+ }
+
+ It "Install-Module multiple names" {
+ Install-Module "TestModuleWithDependencyB", "testmodule99" -Repository PSGallery
+
+ $res = Get-InstalledPSResource "TestModuleWithDependencyB", "testmodule99"
+ $res.Count | Should -BeGreaterOrEqual 2
+ }
+
+ It "Install-Module multiple names with RequiredVersion" {
+ Install-Module "newTestModule", "testmodule99" -RequiredVersion 0.0.1 -Repository PSGallery
+
+ $res = Get-InstalledPSResource "newTestModule", "testmodule99"
+ $res | Should -HaveCount 2
+ }
+
+ It "Install-Multiple names with MinimumVersion" {
+ Install-Module "TestModuleWithDependencyB", "TestModuleWithDependencyD" -MinimumVersion 1.0 -Repository PSGallery
+
+ $res = Get-InstalledPSResource "TestModuleWithDependencyB", "TestModuleWithDependencyD"
+ $res | Should -HaveCount 2
+ foreach ($pkg in $res)
+ {
+ $pkg.Version | Should -BeGreaterOrEqual ([System.Version] "1.0")
+ }
+ }
+
+ It "Install-Module with MinimumVersion" {
+ Install-Module $testModuleName2 -MinimumVersion 0.0.3 -Repository PSGallery
+
+ $res = Get-InstalledPSResource $testModuleName2
+ $res | Should -HaveCount 1
+ $res.Version | Should -BeGreaterOrEqual ([System.Version]"0.0.3")
+ }
+
+ It "Install-Module with RequiredVersion" {
+ Install-Module $testModuleName2 -RequiredVersion 0.0.3 -Repository PSGallery
+
+ $res = Get-InstalledPSResource $testModuleName2
+ $res | Should -HaveCount 1
+ $res.Version | Should -Be ([System.Version]"0.0.3")
+ }
+
+ It "Install-Module should fail if RequiredVersion is already installed" {
+ Install-Module $testModuleName2 -RequiredVersion 0.0.93 -Repository PSGallery
+
+ Install-Module $testModuleName2 -RequiredVersion 0.0.93 -WarningVariable wv -Repository PSGallery
+ $wv[0] | Should -Be "Resource 'testmodule99' with version '0.0.93' is already installed. If you would like to reinstall, please run the cmdlet again with the -Reinstall parameter"
+ }
+
+ It "Install-Module should fail if MinimumVersion is already installed" {
+ Install-Module $testModuleName2 -RequiredVersion 0.0.93 -Repository PSGallery
+
+ Install-Module $testModuleName2 -MinimumVersion 0.0.2 -WarningVariable wv -Repository PSGallery
+ $wv[0] | Should -Be "Resource 'testmodule99' with version '0.0.93' is already installed. If you would like to reinstall, please run the cmdlet again with the -Reinstall parameter"
+ }
+
+ It "Install-Module with -Force" {
+ Install-Module $testModuleName2 -RequiredVersion 0.0.91 -Repository PSGallery
+ Install-Module $testModuleName2 -RequiredVersion 0.0.93 -Force -Repository PSGallery
+
+ $res = Get-InstalledPSResource $testModuleName2
+ $res | Should -HaveCount 2
+ $res.Version | Should -Contain ([System.Version]"0.0.91")
+ $res.Version | Should -Contain ([System.Version]"0.0.93") }
+
+ It "Install-Module same version with -Force" {
+ Install-Module $testModuleName2 -RequiredVersion 0.0.91 -Repository PSGallery
+ Install-Module $testModuleName2 -RequiredVersion 0.0.91 -Force -Repository PSGallery
+
+ $res = Get-InstalledPSResource $testModuleName2
+ $res | Should -HaveCount 1
+ $res.Version | Should -Contain ([System.Version]"0.0.91")
+ }
+
+ It "Install-Module with nonexistent module" {
+ Install-Module NonExistentModule -Repository PSGallery -ErrorVariable ev -ErrorAction SilentlyContinue
+
+ $ev | Should -HaveCount 1
+ }
+
+ It "Install-Module with PipelineInput" {
+ Find-Module $testModuleName2 -Repository PSGallery | Install-Module
+ $res = Get-InstalledPSResource $testModuleName2
+ $res | Should -HaveCount 1
+ }
+
+ It "Install-Module with PipelineInput" {
+ Find-Module $testModuleName2 -Repository PSGallery | Install-Module
+ $res = Get-InstalledPSResource $testModuleName2
+ $res | Should -HaveCount 1
+ }
+
+ It "Install-Module multiple modules with PipelineInput" {
+ Find-Module $testModuleName2, "newTestModule" -Repository PSGallery | Install-Module
+ $res = Get-InstalledPSResource $testModuleName2 , "newTestModule"
+ $res | Should -HaveCount 2
+ }
+
+ It "Install-Module multiple module using InputObjectParam" -Pending {
+ $items = Find-Module $testModuleName2 -Repository PSGallery
+ Install-Module -InputObject $items
+ $res = Get-InstalledPSResource $testModuleName2
+ $res.Count | Should -BeGreaterOrEqual 1
+ }
+
+ It "InstallToCurrentUserScope" {
+ Install-Module $testModuleName2 -Scope CurrentUser -Repository PSGallery
+
+ $mod = Get-Module $testModuleName2 -ListAvailable
+ $mod.ModuleBase.StartsWith($script:MyDocumentsModulesPath, [System.StringComparison]::OrdinalIgnoreCase)
+ }
+
+ It "Install-Module using Find-DscResource output" {
+ $moduleName = 'SystemLocaleDsc'
+ Find-DscResource -Name 'SystemLocale' -Repository PSGallery | Install-Module
+ $res = Get-Module $moduleName -ListAvailable
+ $res.Name | Should -Be $moduleName
+ }
+
+ It "Install-Module using Find-Command Output" {
+ $cmd = "Get-WUJob"
+ $module = "PSWindowsUpdate"
+ Find-Command -Name $cmd | Install-Module
+
+ $res = Get-Module $module -ListAvailable
+ $res.Name | Should -Contain $module
+ }
+
+ It "Install-Module with Dependencies" {
+ $parentModule = "TestModuleWithDependencyC"
+ $childModule1 = "TestModuleWithDependencyB"
+ $childModule2 = "TestModuleWithDependencyD"
+ $childModule3 = "TestModuleWithDependencyF"
+ Install-Module $parentModule -Repository PSGallery
+
+ $res = Get-InstalledPSResource $parentModule, $childModule1, $childModule2, $childModule3
+ $res.Count | Should -BeGreaterOrEqual 4
+ }
+
+ $testCases = @{Name="*"; ErrorId="NameContainsWildcard"},
+ @{Name="Test_Module*"; ErrorId="NameContainsWildcard"},
+ @{Name="Test?Module","Test[Module"; ErrorId="ErrorFilteringNamesForUnsupportedWildcards"}
+
+ It "Should not install resource with wildcard in name" -TestCases $testCases {
+ param($Name, $ErrorId)
+ Install-Module -Name $Name -Repository $PSGalleryName -ErrorVariable err -ErrorAction SilentlyContinue
+ $err.Count | Should -BeGreaterThan 0
+ $err[0].FullyQualifiedErrorId | Should -BeExactly "$ErrorId,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource"
+ }
+
+ It "Install specific module resource by name" {
+ Install-Module -Name $testModuleName2 -Repository $PSGalleryName
+ $pkg = Get-InstalledPSResource $testModuleName2
+ $pkg.Name | Should -Be $testModuleName2
+ $pkg.Version | Should -Be "0.0.93"
+ }
+
+ It "Install specific script resource by name" {
+ Install-Script -Name $testScriptName -Repository $PSGalleryName
+ $pkg = Get-InstalledPSResource $testScriptName
+ $pkg.Name | Should -Be $testScriptName
+ $pkg.Version | Should -Be "3.5.0.0"
+ }
+
+ It "Install multiple resources by name" {
+ $pkgNames = @($testModuleName, $testModuleName2)
+ Install-Module -Name $pkgNames -Repository $PSGalleryName
+ $pkg = Get-InstalledPSResource $pkgNames
+ $pkg.Name | Should -Be $pkgNames
+ }
+
+ It "Should not install module given nonexistant name" {
+ Install-Module -Name "NonExistantModule" -Repository $PSGalleryName -ErrorVariable err -ErrorAction SilentlyContinue
+ $pkg = Get-InstalledPSResource "NonExistantModule"
+ $pkg.Name | Should -BeNullOrEmpty
+ $err.Count | Should -BeGreaterThan 0
+ $err[0].FullyQualifiedErrorId | Should -BeExactly "InstallPackageFailure,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource"
+ }
+
+ It "Should install module given name and exact version" {
+ Install-Module -Name $testModuleName2 -RequiredVersion "0.0.2" -Repository $PSGalleryName
+ $pkg = Get-InstalledPSResource $testModuleName2
+ $pkg.Name | Should -Be $testModuleName2
+ $pkg.Version | Should -Be "0.0.2"
+ }
+
+ It "Install module with latest (including prerelease) version given Prerelease parameter" {
+ Install-Module -Name $testModuleName2 -AllowPrerelease -Repository $PSGalleryName
+ $pkg = Get-InstalledPSResource $testModuleName2
+ $pkg.Name | Should -Be $testModuleName2
+ $pkg.Version | Should -Be "1.0.0"
+ $pkg.Prerelease | Should -Be "beta2"
+ }
+
+ It "Install module via InputObject by piping from Find-PSresource" {
+ Find-PSResource -Name $testModuleName2 -Repository $PSGalleryName | Install-Module
+ $pkg = Get-InstalledPSResource $testModuleName2
+ $pkg.Name | Should -Be $testModuleName2
+ $pkg.Version | Should -Be "0.0.93"
+ }
+
+ It "Install module under specified in PSModulePath" {
+ Install-Module -Name $testModuleName2 -Repository $PSGalleryName
+ $pkg = Get-InstalledPSResource $testModuleName2
+ $pkg.Name | Should -Be $testModuleName2
+ ($env:PSModulePath).Contains($pkg.InstalledLocation)
+ }
+
+ # Windows only
+ It "Install module under CurrentUser scope - Windows only" -Skip:(!(Get-IsWindows)) {
+ Install-Module -Name $testModuleName2 -Repository $PSGalleryName -Scope CurrentUser
+ $pkg = Get-InstalledPSResource $testModuleName2
+ $pkg.Name | Should -Be $testModuleName2
+ $pkg.InstalledLocation.ToString().Contains("Documents") | Should -Be $true
+ }
+
+ # Windows only
+ It "Install module under AllUsers scope - Windows only" -Skip:(!((Get-IsWindows) -and (Test-IsAdmin))) {
+ Install-Module -Name "testmodule99" -Repository $PSGalleryName -Scope AllUsers
+ $pkg = Get-Module "testmodule99" -ListAvailable
+ $pkg.Name | Should -Be "testmodule99"
+ $pkg.Path.ToString().Contains("Program Files")
+ }
+
+ # Windows only
+ It "Install module under no specified scope - Windows only" -Skip:(!(Get-IsWindows)) {
+ Install-Module -Name $testModuleName2 -Repository $PSGalleryName
+ $pkg = Get-InstalledPSResource $testModuleName2
+ $pkg.Name | Should -Be $testModuleName2
+ $pkg.InstalledLocation.ToString().Contains("Documents") | Should -Be $true
+ }
+
+ # Unix only
+ # Expected path should be similar to: '/home/janelane/.local/share/powershell/Modules'
+ It "Install module under CurrentUser scope - Unix only" -Skip:(Get-IsWindows) {
+ Install-Module -Name $testModuleName2 -Repository $PSGalleryName -Scope CurrentUser
+ $pkg = Get-InstalledPSResource $testModuleName2
+ $pkg.Name | Should -Be $testModuleName2
+ $pkg.InstalledLocation.ToString().Contains("$env:HOME/.local") | Should -Be $true
+ }
+
+ # Unix only
+ # Expected path should be similar to: '/home/janelane/.local/share/powershell/Modules'
+ It "Install module under no specified scope - Unix only" -Skip:(Get-IsWindows) {
+ Install-Module -Name $testModuleName2 -Repository $PSGalleryName
+ $pkg = Get-InstalledPSResource $testModuleName2
+ $pkg.Name | Should -Be $testModuleName2
+ $pkg.InstalledLocation.ToString().Contains("$env:HOME/.local") | Should -Be $true
+ }
+
+ It "Should not install module that is already installed" {
+ Install-Module -Name $testModuleName2 -Repository $PSGalleryName
+ $pkg = Get-InstalledPSResource $testModuleName2
+ $pkg.Name | Should -Be $testModuleName2
+ Install-Module -Name $testModuleName2 -Repository $PSGalleryName -WarningVariable WarningVar -warningaction SilentlyContinue
+ $WarningVar | Should -Not -BeNullOrEmpty
+ }
+
+ It "Install resource that requires accept license with -AcceptLicense flag" -Pending {
+ Install-Module -Name "testModuleWithlicense" -Repository $PSGalleryName -AcceptLicense
+ $pkg = Get-InstalledPSResource "testModuleWithlicense"
+ $pkg.Name | Should -Be "testModuleWithlicense"
+ $pkg.Version | Should -Be "0.0.3.0"
+ }
+
+ It "Install resource with cmdlet names from a module already installed (should clobber)" {
+ Install-Module -Name "ClobberTestModule1" -Repository $PSGalleryName
+ $pkg = Get-InstalledPSResource "ClobberTestModule1"
+ $pkg.Name | Should -Be "ClobberTestModule1"
+ $pkg.Version | Should -Be "0.0.1"
+
+ Install-Module -Name "ClobberTestModule2" -Repository $PSGalleryName -AllowClobber
+ $pkg = Get-InstalledPSResource "ClobberTestModule2"
+ $pkg.Name | Should -Be "ClobberTestModule2"
+ $pkg.Version | Should -Be "0.0.1"
+ }
+
+ It "Install module using -WhatIf, should not install the module" {
+ Install-Module -Name $testModuleName2 -WhatIf
+
+ $res = Get-InstalledPSResource $testModuleName2
+ $res | Should -BeNullOrEmpty
+ }
+
+ It "Validates that a module with module-name script files (like Pester) installs under Modules path" {
+ Install-Module -Name "testModuleWithScript" -Repository $PSGalleryName
+
+ $res = Get-InstalledPSResource "testModuleWithScript"
+ $res.InstalledLocation.ToString().Contains("Modules") | Should -Be $true
+ }
+
+ It "Install module using -NoClobber, should throw clobber error and not install the module" -Pending {
+ Install-Module -Name "ClobberTestModule1" -Repository $PSGalleryName
+
+ $res = Get-InstalledPSResource "ClobberTestModule1"
+ $res.Name | Should -Be "ClobberTestModule1"
+
+ Install-Module -Name "ClobberTestModule2" -Repository $PSGalleryName -TrustRepository -NoClobber -ErrorAction SilentlyContinue -ErrorVariable ev
+ $ev | Should -be "CommandAlreadyExists,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource"
+ }
+
+ It "Install PSResourceInfo object piped in" {
+ Find-PSResource -Name $testModuleName2 -Version "0.0.2" -Repository $PSGalleryName | Install-Module
+ $res = Get-InstalledPSResource -Name $testModuleName2
+ $res.Name | Should -Be $testModuleName2
+ $res.Version | Should -Be "0.0.2"
+ }
+
+ # Install module 1.4.3 (is authenticode signed and has catalog file)
+ # Should install successfully
+ It "Install modules with catalog file using publisher validation" -Skip:(!(Get-IsWindows)) {
+ $PackageManagement = "PackageManagement"
+ Install-Module -Name $PackageManagement -RequiredVersion "1.4.3" -Repository $PSGalleryName
+
+ $res1 = Get-InstalledPSResource $PackageManagement -Version "1.4.3"
+ $res1.Name | Should -Be $PackageManagement
+ $res1.Version | Should -Be "1.4.3"
+ }
+
+ # Install 1.4.4.1 (with incorrect catalog file)
+ # Should FAIL to install the module
+ It "Install module with incorrect catalog file" -Skip:(!(Get-IsWindows)) {
+ { Install-Module -Name $PackageManagement -RequiredVersion "1.4.4.1" -Repository $PSGalleryName } | Should -Throw -ErrorId "ParameterArgumentValidationError,Install-Module"
+ }
+
+ # Install script that is signed
+ # Should install successfully
+ It "Install script that is authenticode signed" -Skip:(!(Get-IsWindows)) {
+ Install-Script -Name "Install-VSCode" -RequiredVersion "1.4.2" -Repository $PSGalleryName
+
+ $res1 = Get-InstalledPSResource "Install-VSCode" -Version "1.4.2"
+ $res1.Name | Should -Be "Install-VSCode"
+ $res1.Version | Should -Be "1.4.2"
+ }
+}
+
+# Ensure that PSGet v2 was not loaded during the test via command discovery
+$PSGetVersionsLoaded = (Get-Module powershellget).Version
+Write-Host "PowerShellGet versions currently loaded: $PSGetVersionsLoaded"
+if ($PSGetVersionsLoaded.Count -gt 1) {
+ throw "There was more than one version of PowerShellGet imported into the current session. `
+ Imported versions include: $PSGetVersionsLoaded"
+}
\ No newline at end of file
diff --git a/Test/NewPSScriptFile.Tests.ps1 b/Test/NewPSScriptFile.Tests.ps1
new file mode 100644
index 0000000..a15e504
--- /dev/null
+++ b/Test/NewPSScriptFile.Tests.ps1
@@ -0,0 +1,251 @@
+# Copyright (c) Microsoft Corporation.
+# Licensed under the MIT License.
+
+$modPath = "$psscriptroot/../PSGetTestUtils.psm1"
+Import-Module $modPath -Force -Verbose
+Write-Verbose -Verbose -Message "PowerShellGet version currently loaded: $($(Get-Module powershellget).Version)"
+
+Describe "Test CompatPowerShellGet: New-PSScriptFileInfo" -tags 'CI' {
+ BeforeAll {
+ $tmpDir1Path = Join-Path -Path $TestDrive -ChildPath "tmpDir1"
+ $tmpDirPaths = @($tmpDir1Path)
+ Get-NewTestDirs($tmpDirPaths)
+ }
+ BeforeEach {
+ $script:PSScriptInfoName = "test_script"
+ $script:testScriptFilePath = Join-Path -Path $tmpDir1Path -ChildPath "$script:PSScriptInfoName.ps1"
+ }
+ AfterEach {
+ if (Test-Path -Path $script:testScriptFilePath)
+ {
+ Remove-Item $script:testScriptFilePath
+ }
+ }
+
+ It "Create .ps1 file with minimal required fields" {
+ $description = "Test description"
+ New-ScriptFileInfo -Path $script:testScriptFilePath -Description $description
+ Test-PSScriptFileInfo -Path $script:testScriptFilePath | Should -BeTrue
+ }
+
+ It "Create .ps1 file with relative path" {
+ $relativeCurrentPath = Get-Location
+ $scriptFilePath = Join-Path -Path $relativeCurrentPath -ChildPath "$script:PSScriptInfoName.ps1"
+
+ $description = "Test description"
+ New-ScriptFileInfo -Path $scriptFilePath -Description $description
+
+ Test-PSScriptFileInfo -Path $scriptFilePath | Should -BeTrue
+ Remove-Item -Path $scriptFilePath
+ }
+
+ It "Create new .ps1 given Version parameter" {
+ $version = "2.0.0.0"
+ $description = "Test description"
+
+ New-ScriptFileInfo -Path $script:testScriptFilePath -Version $version -Description $description
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($version) | Should -BeTrue
+ $results.Contains(".VERSION $version") | Should -BeTrue
+ }
+
+ It "Create new .ps1 given Guid parameter" {
+ $guid = [guid]::NewGuid()
+ $description = "Test description"
+
+ New-ScriptFileInfo -Path $script:testScriptFilePath -Guid $guid -Description $description
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($guid) | Should -BeTrue
+ $results.Contains(".GUID $guid") | Should -BeTrue
+ }
+
+ It "Create new .ps1 given Author parameter" {
+ $author = "Test Author"
+ $description = "Test description"
+
+ New-ScriptFileInfo -Path $script:testScriptFilePath -Author $author -Description $description
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($author) | Should -BeTrue
+ $results.Contains(".AUTHOR $author") | Should -BeTrue
+ }
+
+ It "Create new .ps1 given Description parameter" {
+ $description = "PowerShellGet test description"
+
+ New-ScriptFileInfo -Path $script:testScriptFilePath -Description $description
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($description) | Should -BeTrue
+ $results -like "*.DESCRIPTION$script:newline*$description*" | Should -BeTrue
+ }
+
+ It "Create new .ps1 given CompanyName parameter" {
+ $companyName = "Microsoft"
+ $description = "Test description"
+
+ New-ScriptFileInfo -Path $script:testScriptFilePath -CompanyName $companyName -Description $description
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($companyName) | Should -BeTrue
+ $results.Contains(".COMPANYNAME $companyname") | Should -BeTrue
+ }
+
+ It "Create new .ps1 given Copyright parameter" {
+ $copyright = "(c) Test Corporation"
+ $description = "Test description"
+
+ New-ScriptFileInfo -Path $script:testScriptFilePath -Copyright $copyright -Description $description
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($copyright) | Should -BeTrue
+ $results.Contains(".COPYRIGHT $copyright") | Should -BeTrue
+ }
+
+ It "Create new .ps1 given RequiredModules parameter" {
+ $requiredModuleName = 'TestModuleName'
+ $requiredModuleVersion = '1.0.0.0'
+ $RequiredModules = @(@{ModuleName = $requiredModuleName; ModuleVersion = $requiredModuleVersion })
+
+ $description = "Test description"
+
+ New-ScriptFileInfo -Path $script:testScriptFilePath -RequiredModules $RequiredModules -Description $Description
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($requiredModuleName) | Should -BeTrue
+ $results.Contains($requiredModuleVersion) | Should -BeTrue
+ $results -like "*#Requires -Module @{ModuleVersion = '$requiredModuleVersion'; ModuleName = '$requiredModuleName'}*" | Should -BeTrue
+ }
+
+ It "Create new .ps1 given ReleaseNotes parameter" {
+ $description = "Test Description"
+ $releaseNotes = "Release notes for script."
+
+ New-ScriptFileInfo -Path $script:testScriptFilePath -ReleaseNotes $releaseNotes -Description $description
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($releaseNotes) | Should -BeTrue
+ $results -like "*.RELEASENOTES$script:newline*$ReleaseNotes*" | Should -BeTrue
+ }
+
+ It "Create new .ps1 given Tags parameter" {
+ $description = "Test Description"
+ $tag1 = "tag1"
+ $tag2 = "tag2"
+
+ New-ScriptFileInfo -Path $script:testScriptFilePath -Tags $tag1, $tag2 -Description $description
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($tag1) | Should -BeTrue
+ $results.Contains($tag2) | Should -BeTrue
+ $results.Contains(".TAGS $tag1 $tag2") | Should -BeTrue
+ }
+
+ It "Create new .ps1 given ProjectUri parameter" {
+ $description = "Test Description"
+ $projectUri = "https://www.testprojecturi.com/"
+
+ New-ScriptFileInfo -Path $script:testScriptFilePath -ProjectUri $projectUri -Description $description
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($projectUri) | Should -BeTrue
+ $results.Contains(".PROJECTURI $projectUri") | Should -BeTrue
+ }
+
+ It "Create new .ps1 given LicenseUri parameter" {
+ $description = "Test Description"
+ $licenseUri = "https://www.testlicenseuri.com/"
+
+ New-ScriptFileInfo -Path $script:testScriptFilePath -LicenseUri $licenseUri -Description $description
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($licenseUri) | Should -BeTrue
+ $results.Contains(".LICENSEURI $licenseUri") | Should -BeTrue
+ }
+
+ It "Create new .ps1 given IconUri parameter" {
+ $description = "Test Description"
+ $iconUri = "https://www.testiconuri.com/"
+
+ New-ScriptFileInfo -Path $script:testScriptFilePath -IconUri $iconUri -Description $description
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($iconUri) | Should -BeTrue
+ $results.Contains(".ICONURI $iconUri") | Should -BeTrue
+ }
+
+ It "Create new .ps1 given ExternalModuleDependencies parameter" {
+ $description = "Test Description"
+ $externalModuleDep1 = "ExternalModuleDep1"
+ $externalModuleDep2 = "ExternalModuleDep2"
+
+ New-ScriptFileInfo -Path $script:testScriptFilePath -ExternalModuleDependencies $externalModuleDep1, $externalModuleDep2 -Description $description
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($externalModuleDep1) | Should -BeTrue
+ $results.Contains($externalModuleDep2) | Should -BeTrue
+ $results -like "*.EXTERNALMODULEDEPENDENCIES*$externalModuleDep1*$externalModuleDep2*" | Should -BeTrue
+ }
+
+ It "Create new .ps1 given RequiredScripts parameter" {
+ $description = "Test Description"
+ $requiredScript1 = "RequiredScript1"
+ $requiredScript2 = "RequiredScript2"
+
+ New-ScriptFileInfo -Path $script:testScriptFilePath -RequiredScripts $requiredScript1, $requiredScript2 -Description $description
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($requiredScript1) | Should -BeTrue
+ $results.Contains($requiredScript2) | Should -BeTrue
+ $results -like "*.REQUIREDSCRIPTS*$requiredScript1*$requiredScript2*" | Should -BeTrue
+ }
+
+ It "Create new .ps1 given ExternalScriptDependencies parameter" {
+ $description = "Test Description"
+ $externalScriptDep1 = "ExternalScriptDep1"
+ $externalScriptDep2 = "ExternalScriptDep2"
+
+ New-ScriptFileInfo -Path $script:testScriptFilePath -ExternalScriptDependencies $externalScriptDep1, $externalScriptDep2 -Description $description
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($externalScriptDep1) | Should -BeTrue
+ $results.Contains($externalScriptDep2) | Should -BeTrue
+ $results -like "*.EXTERNALSCRIPTDEPENDENCIES*$externalScriptDep1*$externalScriptDep2*" | Should -BeTrue
+ }
+
+ It "Create new .ps1 given PrivateData parameter" {
+ $description = "Test Description"
+ $privateData = @{"PrivateDataEntry1" = "PrivateDataValue1"}
+ New-ScriptFileInfo -Path $script:testScriptFilePath -PrivateData $privateData -Description $description
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($privateData) | Should -BeTrue
+ $results -like "*.PRIVATEDATA*$privateData*" | Should -BeTrue
+ }
+}
+
+# Ensure that PSGet v2 was not loaded during the test via command discovery
+$PSGetVersionsLoaded = (Get-Module powershellget).Version
+Write-Host "PowerShellGet versions currently loaded: $PSGetVersionsLoaded"
+if ($PSGetVersionsLoaded.Count -gt 1) {
+ throw "There was more than one version of PowerShellGet imported into the current session. `
+ Imported versions include: $PSGetVersionsLoaded"
+}
\ No newline at end of file
diff --git a/Test/PSGetModuleInfo.xml b/Test/PSGetModuleInfo.xml
new file mode 100644
index 0000000..8f74623
--- /dev/null
+++ b/Test/PSGetModuleInfo.xml
@@ -0,0 +1,153 @@
+
+
+
+ Microsoft.PowerShell.Commands.PSRepositoryItemInfo
+ System.Management.Automation.PSCustomObject
+ System.Object
+
+
+ Microsoft.PowerShell.SecretManagement
+ 1.1.0-preview2
+ Module
+ This module provides a convenient way for a user to store and retrieve secrets. The secrets are_x000D__x000A_stored in registered extension vaults. An extension vault can store secrets locally or remotely._x000D__x000A_SecretManagement coordinates access to the secrets through the registered vaults._x000D__x000A__x000D__x000A_Go to GitHub for more information about the module and to submit issues:_x000D__x000A_https://github.com/powershell/SecretManagement
+ Microsoft Corporation
+ Microsoft Corporation
+ (c) Microsoft Corporation. All rights reserved.
+ 2021-03-25T18:08:10-07:00
+ true
+
+ 2021-03-25T11:12:41.7662015-07:00
+
+
+
+ Microsoft.PowerShell.Commands.DisplayHintType
+ System.Enum
+ System.ValueType
+ System.Object
+
+ DateTime
+ 2
+
+
+
+
+ https://github.com/PowerShell/SecretManagement/blob/master/LICENSE
+ https://github.com/powershell/secretmanagement
+
+
+
+ System.Object[]
+ System.Array
+ System.Object
+
+
+ PSModule
+ PSEdition_Core
+
+
+
+
+ System.Collections.Hashtable
+ System.Object
+
+
+
+ DscResource
+
+
+
+
+
+
+ RoleCapability
+
+
+
+ Function
+
+
+
+ Cmdlet
+
+
+
+ Register-SecretVault
+ Unregister-SecretVault
+ Get-SecretVault
+ Set-SecretVaultDefault
+ Test-SecretVault
+ Set-Secret
+ Set-SecretInfo
+ Get-Secret
+ Get-SecretInfo
+ Remove-Secret
+
+
+
+
+ Command
+
+
+
+ Register-SecretVault
+ Unregister-SecretVault
+ Get-SecretVault
+ Set-SecretVaultDefault
+ Test-SecretVault
+ Set-Secret
+ Set-SecretInfo
+ Get-Secret
+ Get-SecretInfo
+ Remove-Secret
+
+
+
+
+ Workflow
+
+
+
+
+
+
+
+
+
+
+ https://www.powershellgallery.com/api/v2
+ PSGallery
+ NuGet
+
+
+ System.Management.Automation.PSCustomObject
+ System.Object
+
+
+ (c) Microsoft Corporation. All rights reserved.
+ This module provides a convenient way for a user to store and retrieve secrets. The secrets are_x000D__x000A_stored in registered extension vaults. An extension vault can store secrets locally or remotely._x000D__x000A_SecretManagement coordinates access to the secrets through the registered vaults._x000D__x000A__x000D__x000A_Go to GitHub for more information about the module and to submit issues:_x000D__x000A_https://github.com/powershell/SecretManagement
+ False
+ True
+ True
+ 0
+ 15034
+ 55046
+ 3/25/2021 6:08:10 PM -07:00
+ 3/25/2021 6:08:10 PM -07:00
+ 3/25/2021 6:08:10 PM -07:00
+ PSModule PSEdition_Core PSCmdlet_Register-SecretVault PSCommand_Register-SecretVault PSCmdlet_Unregister-SecretVault PSCommand_Unregister-SecretVault PSCmdlet_Get-SecretVault PSCommand_Get-SecretVault PSCmdlet_Set-SecretVaultDefault PSCommand_Set-SecretVaultDefault PSCmdlet_Test-SecretVault PSCommand_Test-SecretVault PSCmdlet_Set-Secret PSCommand_Set-Secret PSCmdlet_Set-SecretInfo PSCommand_Set-SecretInfo PSCmdlet_Get-Secret PSCommand_Get-Secret PSCmdlet_Get-SecretInfo PSCommand_Get-SecretInfo PSCmdlet_Remove-Secret PSCommand_Remove-Secret PSIncludes_Cmdlet
+ False
+ 2021-03-25T18:08:10Z
+ 1.1.0-preview2
+ Microsoft Corporation
+ true
+ Module
+ Microsoft.PowerShell.SecretManagement.nuspec|Microsoft.PowerShell.SecretManagement.dll|Microsoft.PowerShell.SecretManagement.format.ps1xml|Microsoft.PowerShell.SecretManagement.psd1|en-US\about_Microsoft.PowerShell.SecretManagement.help.txt|en-US\Microsoft.PowerShell.SecretManagement.dll-Help.xml
+ a5c858f6-4a8e-41f1-b1ee-0ff8f6ad69d3
+ 5.1
+ Microsoft Corporation
+
+
+ C:\Users\paulhi\OneDrive - Microsoft\Documents\PowerShell\Modules\Microsoft.PowerShell.SecretManagement\1.0.0
+
+
+
diff --git a/Test/PSGetTestUtils.psm1 b/Test/PSGetTestUtils.psm1
new file mode 100644
index 0000000..8b194f9
--- /dev/null
+++ b/Test/PSGetTestUtils.psm1
@@ -0,0 +1,734 @@
+# Copyright (c) Microsoft Corporation.
+# Licensed under the MIT License.
+
+$script:DotnetCommandPath = @()
+$script:EnvironmentVariableTarget = @{ Process = 0; User = 1; Machine = 2 }
+$script:EnvPATHValueBackup = $null
+
+$script:PowerShellGet = 'PowerShellGet'
+$script:IsInbox = $PSHOME.EndsWith('\WindowsPowerShell\v1.0', [System.StringComparison]::OrdinalIgnoreCase)
+$script:IsWindows = $IsWindows
+if ($IsWindows -eq $null) {
+ $script:IsWindows = ($PSVersionTable.PSVersion.Major -eq 5)
+}
+
+$script:IsLinux = (Get-Variable -Name IsLinux -ErrorAction Ignore) -and $IsLinux
+$script:IsMacOS = (Get-Variable -Name IsMacOS -ErrorAction Ignore) -and $IsMacOS
+$script:IsCoreCLR = $PSVersionTable.ContainsKey('PSEdition') -and $PSVersionTable.PSEdition -eq 'Core'
+
+$script:PSGalleryName = 'PSGallery'
+$script:PSGalleryLocation = 'https://www.powershellgallery.com/api/v2'
+
+$script:NuGetGalleryName = 'NuGetGallery'
+$script:NuGetGalleryLocation = 'https://api.nuget.org/v3/index.json'
+
+if($script:IsInbox)
+{
+ $script:ProgramFilesPSPath = Microsoft.PowerShell.Management\Join-Path -Path $env:ProgramFiles -ChildPath "WindowsPowerShell"
+}
+elseif($script:IsCoreCLR){
+ if($script:IsWindows) {
+ $script:ProgramFilesPSPath = Microsoft.PowerShell.Management\Join-Path -Path $env:ProgramFiles -ChildPath 'PowerShell'
+ }
+ else {
+ $script:ProgramFilesPSPath = Split-Path -Path ([System.Management.Automation.Platform]::SelectProductNameForDirectory('SHARED_MODULES')) -Parent
+ }
+}
+
+try
+{
+ $script:MyDocumentsFolderPath = [Environment]::GetFolderPath("MyDocuments")
+}
+catch
+{
+ $script:MyDocumentsFolderPath = $null
+}
+
+if($script:IsInbox)
+{
+ $script:MyDocumentsPSPath = if($script:MyDocumentsFolderPath)
+ {
+ Microsoft.PowerShell.Management\Join-Path -Path $script:MyDocumentsFolderPath -ChildPath "WindowsPowerShell"
+ }
+ else
+ {
+ Microsoft.PowerShell.Management\Join-Path -Path $env:USERPROFILE -ChildPath "Documents\WindowsPowerShell"
+ }
+}
+elseif($script:IsCoreCLR) {
+ if($script:IsWindows)
+ {
+ $script:MyDocumentsPSPath = if($script:MyDocumentsFolderPath)
+ {
+ Microsoft.PowerShell.Management\Join-Path -Path $script:MyDocumentsFolderPath -ChildPath 'PowerShell'
+ }
+ else
+ {
+ Microsoft.PowerShell.Management\Join-Path -Path $HOME -ChildPath "Documents\PowerShell"
+ }
+ }
+ else
+ {
+ $script:MyDocumentsPSPath = Split-Path -Path ([System.Management.Automation.Platform]::SelectProductNameForDirectory('USER_MODULES')) -Parent
+ }
+}
+
+$script:ProgramFilesModulesPath = Microsoft.PowerShell.Management\Join-Path -Path $script:ProgramFilesPSPath -ChildPath 'Modules'
+$script:MyDocumentsModulesPath = Microsoft.PowerShell.Management\Join-Path -Path $script:MyDocumentsPSPath -ChildPath 'Modules'
+$script:ProgramFilesScriptsPath = Microsoft.PowerShell.Management\Join-Path -Path $script:ProgramFilesPSPath -ChildPath 'Scripts'
+$script:MyDocumentsScriptsPath = Microsoft.PowerShell.Management\Join-Path -Path $script:MyDocumentsPSPath -ChildPath 'Scripts'
+$script:TempPath = [System.IO.Path]::GetTempPath()
+
+if($script:IsWindows) {
+ $script:PSGetProgramDataPath = Microsoft.PowerShell.Management\Join-Path -Path $env:ProgramData -ChildPath 'Microsoft\Windows\PowerShell\PowerShellGet\'
+ $script:PSGetAppLocalPath = Microsoft.PowerShell.Management\Join-Path -Path $env:LOCALAPPDATA -ChildPath 'Microsoft\Windows\PowerShell\PowerShellGet\'
+} else {
+ $script:PSGetProgramDataPath = Join-Path -Path ([System.Management.Automation.Platform]::SelectProductNameForDirectory('CONFIG')) -ChildPath 'PowerShellGet'
+ $script:PSGetAppLocalPath = Join-Path -Path ([System.Management.Automation.Platform]::SelectProductNameForDirectory('CACHE')) -ChildPath 'PowerShellGet'
+}
+
+$script:ProgramDataExePath = Microsoft.PowerShell.Management\Join-Path -Path $script:PSGetProgramDataPath -ChildPath $script:NuGetExeName
+$script:ApplocalDataExePath = Microsoft.PowerShell.Management\Join-Path -Path $script:PSGetAppLocalPath -ChildPath $script:NuGetExeName
+$script:moduleSourcesFilePath = Microsoft.PowerShell.Management\Join-Path -Path $script:PSGetAppLocalPath -ChildPath 'PSRepositories.xml'
+
+# PowerShellGetFormatVersion will be incremented when we change the .nupkg format structure.
+# PowerShellGetFormatVersion is in the form of Major.Minor.
+# Minor is incremented for the backward compatible format change.
+# Major is incremented for the breaking change.
+$script:CurrentPSGetFormatVersion = "1.0"
+$script:PSGetFormatVersionPrefix = "PowerShellGetFormatVersion_"
+
+function Test-IsAdmin {
+ [OutputType([bool])]
+ param()
+
+ [System.Security.Principal.WindowsPrincipal]::new(
+ [Security.Principal.WindowsIdentity]::GetCurrent()
+ ).IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)
+}
+
+function Get-IsWindows {
+ return $script:IsWindows
+}
+
+function Get-AllUsersModulesPath {
+ return $script:ProgramFilesModulesPath
+}
+
+function Get-CurrentUserModulesPath {
+ return $script:MyDocumentsModulesPath
+}
+
+function Get-AllUsersScriptsPath {
+ return $script:ProgramFilesScriptsPath
+}
+
+function Get-CurrentUserScriptsPath {
+ return $script:MyDocumentsScriptsPath
+}
+
+function Get-TempPath {
+ return $script:TempPath
+}
+
+function Get-PSGetLocalAppDataPath {
+ return $script:PSGetAppLocalPath
+}
+
+function Get-NuGetGalleryName
+{
+ return $script:NuGetGalleryName
+}
+
+function Get-NuGetGalleryLocation
+{
+ return $script:NuGetGalleryLocation
+}
+
+function Get-PSGalleryName
+{
+ return $script:PSGalleryName
+}
+
+function Get-PSGalleryLocation {
+ return $script:PSGalleryLocation
+}
+function Get-NewTestDirs {
+ Param(
+ [string[]]
+ $listOfPaths
+ )
+ foreach($path in $listOfPaths)
+ {
+ $null = New-Item -Path $path -ItemType Directory
+ }
+}
+
+function Get-RemoveTestDirs {
+ Param(
+ [string[]]
+ $listOfPaths
+ )
+ foreach($path in $listOfPaths)
+ {
+ if(Test-Path -Path $path)
+ {
+ Remove-Item -Path $path -Force -ErrorAction Ignore
+ }
+ }
+}
+
+function Get-NewPSResourceRepositoryFile {
+ # register our own repositories with desired priority
+ $powerShellGetPath = Join-Path -Path ([Environment]::GetFolderPath([System.Environment+SpecialFolder]::LocalApplicationData)) -ChildPath "PowerShellGet"
+ $originalXmlFilePath = Join-Path -Path $powerShellGetPath -ChildPath "PSResourceRepository.xml"
+ $tempXmlFilePath = Join-Path -Path $powerShellGetPath -ChildPath "temp.xml"
+
+ if (Test-Path -Path $originalXmlFilePath) {
+ Copy-Item -Path $originalXmlFilePath -Destination $tempXmlFilePath
+ Remove-Item -Path $originalXmlFilePath -Force -ErrorAction Ignore
+ }
+
+ if (! (Test-Path -Path $powerShellGetPath)) {
+ $null = New-Item -Path $powerShellGetPath -ItemType Directory -Verbose
+ }
+
+ $fileToCopy = Join-Path -Path $PSScriptRoot -ChildPath "testRepositories.xml"
+ Copy-Item -Path $fileToCopy -Destination $originalXmlFilePath -Force -Verbose
+}
+
+function Get-RevertPSResourceRepositoryFile {
+ $powerShellGetPath = Join-Path -Path ([Environment]::GetFolderPath([System.Environment+SpecialFolder]::LocalApplicationData)) -ChildPath "PowerShellGet"
+ $originalXmlFilePath = Join-Path -Path $powerShellGetPath -ChildPath "PSResourceRepository.xml"
+ $tempXmlFilePath = Join-Path -Path $powerShellGetPath -ChildPath "temp.xml"
+
+ if (Test-Path -Path $tempXmlFilePath) {
+ Remove-Item -Path $originalXmlFilePath -Force -ErrorAction Ignore
+ Copy-Item -Path $tempXmlFilePath -Destination $originalXmlFilePath -Force
+ Remove-Item -Path $tempXmlFilePath -Force -ErrorAction Ignore
+ }
+}
+
+function Get-NewPSResourceRepositoryFileWithCredentialInfo {
+ # register our own repositories with desired priority
+ $powerShellGetPath = Join-Path -Path ([Environment]::GetFolderPath([System.Environment+SpecialFolder]::LocalApplicationData)) -ChildPath "PowerShellGet"
+ $originalXmlFilePath = Join-Path -Path $powerShellGetPath -ChildPath "PSResourceRepository.xml"
+ $tempXmlFilePath = Join-Path -Path $powerShellGetPath -ChildPath "temp.xml"
+
+ if (Test-Path -Path $originalXmlFilePath) {
+ Copy-Item -Path $originalXmlFilePath -Destination $tempXmlFilePath
+ Remove-Item -Path $originalXmlFilePath -Force -ErrorAction Ignore
+ }
+
+ if (! (Test-Path -Path $powerShellGetPath)) {
+ $null = New-Item -Path $powerShellGetPath -ItemType Directory -Verbose
+ }
+
+ $fileToCopy = Join-Path -Path $PSScriptRoot -ChildPath "testRepositoriesWithCredentialInfo.xml"
+ Copy-Item -Path $fileToCopy -Destination $originalXmlFilePath -Force -Verbose
+}
+
+function Register-LocalRepos {
+ $repoUriAddress = Join-Path -Path $TestDrive -ChildPath "testdir"
+ $null = New-Item $repoUriAddress -ItemType Directory -Force
+ $localRepoParams = @{
+ Name = "psgettestlocal"
+ Uri = $repoUriAddress
+ Priority = 40
+ Trusted = $false
+ }
+ Register-PSResourceRepository @localRepoParams
+
+ $repoUriAddress2 = Join-Path -Path $TestDrive -ChildPath "testdir2"
+ $null = New-Item $repoUriAddress2 -ItemType Directory -Force
+ $localRepoParams2 = @{
+ Name = "psgettestlocal2"
+ Uri = $repoUriAddress2
+ Priority = 50
+ Trusted = $false
+ }
+ Register-PSResourceRepository @localRepoParams2
+ Write-Verbose("registered psgettestlocal, psgettestlocal2")
+}
+
+function Register-PSGallery {
+ $PSGalleryRepoParams = @{
+ Name = $script:PSGalleryName
+ Uri = $script:PSGalleryLocation
+ Priority = 1
+ Trusted = $false
+ }
+ Register-PSResourceRepository @PSGalleryRepoParams
+
+ Write-Verbose("registered PSGallery")
+}
+
+function Unregister-LocalRepos {
+ if(Get-PSResourceRepository -Name "psgettestlocal"){
+ Unregister-PSResourceRepository -Name "psgettestlocal"
+ }
+ if(Get-PSResourceRepository -Name "psgettestlocal2"){
+ Unregister-PSResourceRepository -Name "psgettestlocal2"
+ }
+}
+function Get-TestDriveSetUp
+{
+ $testResourcesFolder = Join-Path $TestDrive -ChildPath "TestLocalDirectory"
+
+ $script:testIndividualResourceFolder = Join-Path -Path $testResourcesFolder -ChildPath "PSGet_$(Get-Random)"
+ $null = New-Item -Path $testIndividualResourceFolder -ItemType Directory -Force
+}
+
+function Get-RoleCapabilityResourcePublishedToLocalRepoTestDrive
+{
+ Param(
+ [string]
+ $roleCapName
+ )
+
+ Get-TestDriveSetUp
+
+ $publishModuleName = $roleCapName
+ $publishModuleBase = Join-Path $script:testIndividualResourceFolder $publishModuleName
+ $null = New-Item -Path $publishModuleBase -ItemType Directory -Force
+
+ $version = "1.0"
+ New-PSRoleCapabilityFile -Path (Join-Path -Path $publishModuleBase -ChildPath "$publishModuleName.psrc")
+ New-ModuleManifest -Path (Join-Path -Path $publishModuleBase -ChildPath "$publishModuleName.psd1") -ModuleVersion $version -Description "$publishModuleName module" -NestedModules "$publishModuleName.psm1" -DscResourcesToExport @('DefaultGatewayAddress', 'WINSSetting') -Tags @('PSDscResource_', 'DSC')
+
+ Publish-PSResource -Path $publishModuleBase -Repository psgettestlocal
+}
+
+function Get-DSCResourcePublishedToLocalRepoTestDrive
+{
+ Param(
+ [string]
+ $dscName
+ )
+
+ Get-TestDriveSetUp
+
+ $publishModuleName = $dscName
+ $publishModuleBase = Join-Path $script:testIndividualResourceFolder $publishModuleName
+ $null = New-Item -Path $publishModuleBase -ItemType Directory -Force
+
+ $version = "1.0"
+ New-ModuleManifest -Path (Join-Path -Path $publishModuleBase -ChildPath "$publishModuleName.psd1") -ModuleVersion $version -Description "$publishModuleName module" -NestedModules "$publishModuleName.psm1" -DscResourcesToExport @('DefaultGatewayAddress', 'WINSSetting') -Tags @('PSDscResource_', 'DSC')
+
+ Publish-PSResource -Path $publishModuleBase -Repository psgettestlocal
+}
+
+function Get-ScriptResourcePublishedToLocalRepoTestDrive
+{
+ Param(
+ [string]
+ $scriptName,
+
+ [string]
+ $scriptRepoName,
+
+ [string]
+ $scriptVersion
+ )
+ Get-TestDriveSetUp
+
+ $scriptFilePath = Join-Path -Path $script:testIndividualResourceFolder -ChildPath "$scriptName.ps1"
+ $null = New-Item -Path $scriptFilePath -ItemType File -Force
+
+ $params = @{
+ Version = $scriptVersion
+ GUID = [guid]::NewGuid()
+ Author = 'Jane'
+ CompanyName = 'Microsoft Corporation'
+ Copyright = '(c) 2020 Microsoft Corporation. All rights reserved.'
+ Description = "Description for the $scriptName script"
+ LicenseUri = "https://$scriptName.com/license"
+ IconUri = "https://$scriptName.com/icon"
+ ProjectUri = "https://$scriptName.com"
+ Tags = @('Tag1','Tag2', "Tag-$scriptName-$scriptVersion")
+ ReleaseNotes = "$scriptName release notes"
+ }
+
+ $scriptMetadata = Create-PSScriptMetadata @params
+ Set-Content -Path $scriptFilePath -Value $scriptMetadata
+ Publish-PSResource -Path $scriptFilePath -Repository $scriptRepoName -Verbose
+}
+
+function Get-CommandResourcePublishedToLocalRepoTestDrive
+{
+ Param(
+ [string]
+ $cmdName
+ )
+ Get-TestDriveSetUp
+
+ $publishModuleName = $cmdName
+ $publishModuleBase = Join-Path $script:testIndividualResourceFolder $publishModuleName
+ $null = New-Item -Path $publishModuleBase -ItemType Directory -Force
+
+ $version = "1.0"
+ New-ModuleManifest -Path (Join-Path -Path $publishModuleBase -ChildPath "$publishModuleName.psd1") -ModuleVersion $version -Description "$publishModuleName module" -NestedModules "$publishModuleName.psm1" -CmdletsToExport @('Get-Test', 'Set-Test')
+
+ Publish-PSResource -Path $publishModuleBase -Repository psgettestlocal
+}
+
+function Get-ModuleResourcePublishedToLocalRepoTestDrive
+{
+ Param(
+ [string]
+ $moduleName,
+
+ [string]
+ $repoName
+ )
+ Get-TestDriveSetUp
+
+ $publishModuleName = $moduleName
+ $publishModuleBase = Join-Path $script:testIndividualResourceFolder $publishModuleName
+ $null = New-Item -Path $publishModuleBase -ItemType Directory -Force
+
+ $version = "1.0"
+ New-ModuleManifest -Path (Join-Path -Path $publishModuleBase -ChildPath "$publishModuleName.psd1") -ModuleVersion $version -Description "$publishModuleName module"
+
+ Publish-PSResource -Path $publishModuleBase -Repository $repoName
+}
+
+function Create-TagsStringEntry
+{
+ Param(
+ [string[]]
+ $tags
+ )
+
+ if (!$tags)
+ {
+ return ""
+ }
+
+ $tagsString = "Tags = @(" + ($tags -join ",") + ")"
+ return $tagsString
+}
+
+function New-TestModule
+{
+ Param(
+ [string]
+ $path = "$TestDrive",
+
+ [string]
+ $moduleName = "TestModule",
+
+ [string]
+ $repoName,
+
+ [string]
+ $packageVersion,
+
+ [string]
+ $prereleaseLabel,
+
+ [string[]]
+ $tags
+ )
+
+ $modulePath = Join-Path -Path $path -ChildPath $ModuleName
+ $moduleMan = Join-Path $modulePath -ChildPath ($ModuleName + '.psd1')
+
+ if ( Test-Path -Path $modulePath) {
+ Remove-Item -Path $modulePath -Recurse -Force
+ }
+
+ $null = New-Item -Path $modulePath -ItemType Directory -Force
+ $tagsEntry = Create-TagsStringEntry -tags $tags
+ $prereleaseEntry = ""
+ if ($prereleaseLabel)
+ {
+ $prereleaseEntry = "Prerelease = '{0}'" -f $prereleaseLabel
+ }
+
+ @'
+ @{{
+ ModuleVersion = '{0}'
+ Author = 'None'
+ Description = 'None'
+ GUID = '0c2829fc-b165-4d72-9038-ae3a71a755c1'
+ FunctionsToExport = @()
+ RequiredModules = @()
+ PrivateData = @{{
+ PSData = @{{
+ {1}
+ {2}
+ }}
+ }}
+ }}
+'@ -f $packageVersion, $prereleaseEntry, $tagsEntry | Out-File -FilePath $moduleMan
+
+ Publish-PSResource -Path $modulePath -Repository $repoName
+}
+
+function Get-ModuleResourcePublishedToLocalRepoTestDrive
+{
+ Param(
+ [string]
+ $moduleName,
+
+ [string]
+ $repoName,
+
+ [string]
+ $packageVersion,
+
+ [string]
+ $prereleaseLabel,
+
+ [string[]]
+ $tags
+ )
+ Get-TestDriveSetUp
+
+ $publishModuleName = $moduleName
+ $publishModuleBase = Join-Path $script:testIndividualResourceFolder $publishModuleName
+ $null = New-Item -Path $publishModuleBase -ItemType Directory -Force
+
+ $version = $packageVersion
+ if (!$tags -or ($tags.Count -eq 0))
+ {
+ if (!$prereleaseLabel)
+ {
+ New-ModuleManifest -Path (Join-Path -Path $publishModuleBase -ChildPath "$publishModuleName.psd1") -ModuleVersion $version -Description "$publishModuleName module"
+ }
+ else
+ {
+ New-ModuleManifest -Path (Join-Path -Path $publishModuleBase -ChildPath "$publishModuleName.psd1") -ModuleVersion $version -Prerelease $prereleaseLabel -Description "$publishModuleName module"
+ }
+ }
+ else {
+ # tags is not null or is empty
+ if (!$prereleaseLabel)
+ {
+ New-ModuleManifest -Path (Join-Path -Path $publishModuleBase -ChildPath "$publishModuleName.psd1") -ModuleVersion $version -Description "$publishModuleName module" -Tags $tags
+ }
+ else
+ {
+ New-ModuleManifest -Path (Join-Path -Path $publishModuleBase -ChildPath "$publishModuleName.psd1") -ModuleVersion $version -Prerelease $prereleaseLabel -Description "$publishModuleName module" -Tags $tags
+ }
+ }
+
+ Publish-PSResource -Path $publishModuleBase -Repository $repoName
+}
+
+function Register-LocalRepos {
+ $repoUriAddress = Join-Path -Path $TestDrive -ChildPath "testdir"
+ $null = New-Item $repoUriAddress -ItemType Directory -Force
+ $localRepoParams = @{
+ Name = "psgettestlocal"
+ Uri = $repoUriAddress
+ Priority = 40
+ Trusted = $false
+ }
+
+ Register-PSResourceRepository @localRepoParams
+
+ $repoUriAddress2 = Join-Path -Path $TestDrive -ChildPath "testdir2"
+ $null = New-Item $repoUriAddress2 -ItemType Directory -Force
+ $localRepoParams2 = @{
+ Name = "psgettestlocal2"
+ Uri = $repoUriAddress2
+ Priority = 50
+ Trusted = $false
+ }
+
+ Register-PSResourceRepository @localRepoParams2
+}
+function RemoveItem
+{
+ Param(
+ [string]
+ $path
+ )
+
+ if($path -and (Test-Path $path))
+ {
+ Remove-Item $path -Force -Recurse -ErrorAction SilentlyContinue
+ }
+}
+
+function Create-PSScriptMetadata
+{
+ [OutputType([String])]
+ [CmdletBinding(PositionalBinding=$false,
+ SupportsShouldProcess=$true)]
+
+ Param
+ (
+ [Parameter()]
+ [ValidateNotNullOrEmpty()]
+ [string]
+ $Version,
+
+ [Parameter()]
+ #[ValidateNotNullOrEmpty()]
+ [Guid]
+ $Guid,
+
+ [Parameter()]
+ [ValidateNotNullOrEmpty()]
+ [string]
+ $Author,
+
+ [Parameter()]
+ [String]
+ $CompanyName,
+
+ [Parameter()]
+ [string]
+ $Copyright,
+
+ [Parameter()]
+ [string]
+ $Description,
+
+ [Parameter()]
+ [String[]]
+ $ExternalModuleDependencies,
+
+ [Parameter()]
+ [string[]]
+ $RequiredScripts,
+
+ [Parameter()]
+ [String[]]
+ $ExternalScriptDependencies,
+
+ [Parameter()]
+ [string[]]
+ $Tags,
+
+ [Parameter()]
+ [Uri]
+ $ProjectUri,
+
+ [Parameter()]
+ [Uri]
+ $LicenseUri,
+
+ [Parameter()]
+ [Uri]
+ $IconUri,
+
+ [Parameter()]
+ [string[]]
+ $ReleaseNotes,
+
+ [Parameter()]
+ [string]
+ $PrivateData
+ )
+
+ Process
+ {
+ $PSScriptInfoString = @"
+
+<#PSScriptInfo
+
+.VERSION$(if ($Version) {" $Version"})
+
+.GUID$(if ($Guid) {" $Guid"})
+
+.AUTHOR$(if ($Author) {" $Author"})
+
+.COMPANYNAME$(if ($CompanyName) {" $CompanyName"})
+
+.COPYRIGHT$(if ($Copyright) {" $Copyright"})
+
+.TAGS$(if ($Tags) {" $Tags"})
+
+.LICENSEURI$(if ($LicenseUri) {" $LicenseUri"})
+
+.PROJECTURI$(if ($ProjectUri) {" $ProjectUri"})
+
+.ICONURI$(if ($IconUri) {" $IconUri"})
+
+.EXTERNALMODULEDEPENDENCIES$(if ($ExternalModuleDependencies) {" $($ExternalModuleDependencies -join ',')"})
+
+.REQUIREDSCRIPTS$(if ($RequiredScripts) {" $($RequiredScripts -join ',')"})
+
+.EXTERNALSCRIPTDEPENDENCIES$(if ($ExternalScriptDependencies) {" $($ExternalScriptDependencies -join ',')"})
+
+.RELEASENOTES
+$($ReleaseNotes -join "`r`n")
+
+.PRIVATEDATA$(if ($PrivateData) {" $PrivateData"})
+
+#>
+
+<#
+
+.DESCRIPTION
+$(if ($Description) {" $Description"})
+
+#>
+"@
+ return $PSScriptInfoString
+ }
+}
+
+<#
+Checks that provided PSGetInfo object contents match the expected data
+from the test information file: PSGetModuleInfo.xml
+#>
+
+function CheckForExpectedPSGetInfo
+{
+ param ($psGetInfo)
+
+ $psGetInfo.AdditionalMetadata.Keys | Should -HaveCount 22
+ $psGetInfo.AdditionalMetadata['copyright'] | Should -BeExactly '(c) Microsoft Corporation. All rights reserved.'
+ $psGetInfo.AdditionalMetadata['description'] | Should -BeLike 'This module provides a convenient way for a user to store and retrieve secrets*'
+ $psGetInfo.AdditionalMetadata['requireLicenseAcceptance'] | Should -BeExactly 'False'
+ $psGetInfo.AdditionalMetadata['isLatestVersion'] | Should -BeExactly 'True'
+ $psGetInfo.AdditionalMetadata['isAbsoluteLatestVersion'] | Should -BeExactly 'True'
+ $psGetInfo.AdditionalMetadata['versionDownloadCount'] | Should -BeExactly '0'
+ $psGetInfo.AdditionalMetadata['downloadCount'] | Should -BeExactly '15034'
+ $psGetInfo.AdditionalMetadata['packageSize'] | Should -BeExactly '55046'
+ $psGetInfo.AdditionalMetadata['published'] | Should -BeExactly '3/25/2021 6:08:10 PM -07:00'
+ $psGetInfo.AdditionalMetadata['created'] | Should -BeExactly '3/25/2021 6:08:10 PM -07:00'
+ $psGetInfo.AdditionalMetadata['lastUpdated'] | Should -BeExactly '3/25/2021 6:08:10 PM -07:00'
+ $psGetInfo.AdditionalMetadata['tags'] | Should -BeLike 'PSModule PSEdition_Core PSCmdlet_Register-SecretVault*'
+ $psGetInfo.AdditionalMetadata['developmentDependency'] | Should -BeExactly 'False'
+ $psGetInfo.AdditionalMetadata['updated'] | Should -BeExactly '2021-03-25T18:08:10Z'
+ $psGetInfo.AdditionalMetadata['NormalizedVersion'] | Should -BeExactly '1.1.0-preview2'
+ $psGetInfo.AdditionalMetadata['Authors'] | Should -BeExactly 'Microsoft Corporation'
+ $psGetInfo.AdditionalMetadata['IsPrerelease'] | Should -Be $True
+ $psGetInfo.AdditionalMetadata['ItemType'] | Should -BeExactly 'Module'
+ $psGetInfo.AdditionalMetadata['FileList'] | Should -BeLike 'Microsoft.PowerShell.SecretManagement.nuspec|Microsoft.PowerShell.SecretManagement.dll*'
+ $psGetInfo.AdditionalMetadata['GUID'] | Should -BeExactly 'a5c858f6-4a8e-41f1-b1ee-0ff8f6ad69d3'
+ $psGetInfo.AdditionalMetadata['PowerShellVersion'] | Should -BeExactly '5.1'
+ $psGetInfo.AdditionalMetadata['CompanyName'] | Should -BeExactly 'Microsoft Corporation'
+ #
+ $psGetInfo.Author | Should -BeExactly 'Microsoft Corporation'
+ $psGetInfo.CompanyName | Should -BeExactly 'Microsoft Corporation'
+ $psGetInfo.Copyright | Should -BeExactly '(c) Microsoft Corporation. All rights reserved.'
+ $psGetInfo.Dependencies | Should -HaveCount 0
+ $psGetInfo.Description | Should -BeLike 'This module provides a convenient way for a user to store*'
+ $psGetInfo.IconUri | Should -BeNullOrEmpty
+ $psGetInfo.IsPrerelease | Should -Be $True
+ $psGetInfo.Prerelease | Should -Be "preview2"
+ $psGetInfo.Includes.Cmdlet | Should -HaveCount 10
+ $psGetInfo.Includes.Cmdlet[0] | Should -BeExactly 'Register-SecretVault'
+ $psGetInfo.InstalledDate.Year | Should -BeExactly 2021
+ $psGetInfo.InstalledLocation | Should -BeLike 'C:\Users\*'
+ $psGetInfo.LicenseUri | Should -BeExactly 'https://github.com/PowerShell/SecretManagement/blob/master/LICENSE'
+ $psGetInfo.Name | Should -BeExactly 'Microsoft.PowerShell.SecretManagement'
+ $psGetInfo.PackageManagementProvider | Should -BeExactly 'NuGet'
+ $psGetInfo.PowerShellGetFormatVersion | Should -BeNullOrEmpty
+ $psGetInfo.ProjectUri | Should -BeExactly 'https://github.com/powershell/secretmanagement'
+ $psGetInfo.PublishedDate.Year | Should -BeExactly 2021
+ $psGetInfo.ReleasedNotes | Should -BeNullOrEmpty
+ $psGetInfo.Repository | Should -BeExactly 'PSGallery'
+ $psGetInfo.RepositorySourceLocation | Should -BeExactly 'https://www.powershellgallery.com/api/v2'
+ $psGetInfo.Tags | Should -BeExactly @('PSModule', 'PSEdition_Core')
+ $psGetInfo.Type | Should -BeExactly 'Module'
+ $psGetInfo.UpdatedDate.Year | Should -BeExactly 1
+ $psGetInfo.Version | Should -Be "1.1.0"
+}
diff --git a/Test/Proxy.Tests.ps1 b/Test/Proxy.Tests.ps1
index 26c4737..df03140 100644
--- a/Test/Proxy.Tests.ps1
+++ b/Test/Proxy.Tests.ps1
@@ -13,7 +13,7 @@ Describe "Proxies exist" {
$skipTest = $true
}
# be sure that this module is loaded
- $proxyModuleName = "PowerShellGetCompat"
+ $proxyModuleName = "CompatPowerShellGet"
$unloadModule = $false
if ( ! (Get-Module $proxyModuleName) ) {
$unloadModule = $true
diff --git a/Test/PublishPSResource.Tests.ps1 b/Test/PublishPSResource.Tests.ps1
new file mode 100644
index 0000000..ec559dc
--- /dev/null
+++ b/Test/PublishPSResource.Tests.ps1
@@ -0,0 +1,371 @@
+# Copyright (c) Microsoft Corporation.
+# Licensed under the MIT License.
+
+$modPath = "$psscriptroot/../PSGetTestUtils.psm1"
+Import-Module $modPath -Force -Verbose
+Write-Verbose -Verbose -Message "PowerShellGet version currently loaded: $($(Get-Module powershellget).Version)"
+$testDir = (get-item $psscriptroot).parent.FullName
+
+function CreateTestModule
+{
+ param (
+ [string] $Path = "$TestDrive",
+ [string] $ModuleName = 'TestModule'
+ )
+
+ $modulePath = Join-Path -Path $Path -ChildPath $ModuleName
+ $moduleMan = Join-Path $modulePath -ChildPath ($ModuleName + '.psd1')
+ $moduleSrc = Join-Path $modulePath -ChildPath ($ModuleName + '.psm1')
+
+ if ( Test-Path -Path $modulePath) {
+ Remove-Item -Path $modulePath -Recurse -Force
+ }
+
+ $null = New-Item -Path $modulePath -ItemType Directory -Force
+
+ @'
+ @{{
+ RootModule = "{0}.psm1"
+ ModuleVersion = '1.0.0'
+ Author = 'None'
+ Description = 'None'
+ GUID = '0c2829fc-b165-4d72-9038-ae3a71a755c1'
+ FunctionsToExport = @('Test1')
+ RequiredModules = @('NonExistentModule')
+ }}
+'@ -f $ModuleName | Out-File -FilePath $moduleMan
+
+ @'
+ function Test1 {
+ Write-Output 'Hello from Test1'
+ }
+'@ | Out-File -FilePath $moduleSrc
+}
+
+Describe "Test CompatPowerShellGet: Publish-PSResource" -tags 'CI' {
+ BeforeAll {
+ Get-NewPSResourceRepositoryFile
+
+ # Register temporary repositories
+ $tmpRepoPath = Join-Path -Path $TestDrive -ChildPath "tmpRepoPath"
+ New-Item $tmpRepoPath -Itemtype directory -Force
+ $testRepository = "testRepository"
+ Register-PSResourceRepository -Name $testRepository -Uri $tmpRepoPath -Priority 1 -ErrorAction SilentlyContinue
+ $script:repositoryPath = [IO.Path]::GetFullPath((get-psresourcerepository "testRepository").Uri.AbsolutePath)
+
+ $tmpRepoPath2 = Join-Path -Path $TestDrive -ChildPath "tmpRepoPath2"
+ New-Item $tmpRepoPath2 -Itemtype directory -Force
+ $testRepository2 = "testRepository2"
+ Register-PSResourceRepository -Name $testRepository2 -Uri $tmpRepoPath2 -ErrorAction SilentlyContinue
+ $script:repositoryPath2 = [IO.Path]::GetFullPath((get-psresourcerepository "testRepository2").Uri.AbsolutePath)
+
+ # Create module
+ $script:tmpModulesPath = Join-Path -Path $TestDrive -ChildPath "tmpModulesPath"
+ $script:PublishModuleName = "PSGetTestModule"
+ $script:PublishModuleBase = Join-Path $script:tmpModulesPath -ChildPath $script:PublishModuleName
+ if(!(Test-Path $script:PublishModuleBase))
+ {
+ New-Item -Path $script:PublishModuleBase -ItemType Directory -Force
+ }
+
+ #Create dependency module
+ $script:DependencyModuleName = "PackageManagement"
+ $script:DependencyModuleBase = Join-Path $script:tmpModulesPath -ChildPath $script:DependencyModuleName
+ if(!(Test-Path $script:DependencyModuleBase))
+ {
+ New-Item -Path $script:DependencyModuleBase -ItemType Directory -Force
+ }
+
+ # Create temp destination path
+ $script:destinationPath = [IO.Path]::GetFullPath((Join-Path -Path $TestDrive -ChildPath "tmpDestinationPath"))
+ New-Item $script:destinationPath -ItemType directory -Force
+
+ #Create folder where we shall place all script files to be published for these tests
+ $script:tmpScriptsFolderPath = Join-Path -Path $TestDrive -ChildPath "tmpScriptsPath"
+ if(!(Test-Path $script:tmpScriptsFolderPath))
+ {
+ New-Item -Path $script:tmpScriptsFolderPath -ItemType Directory -Force
+ }
+
+ # Path to folder, within our test folder, where we store invalid module and script files used for testing
+ $script:testFilesFolderPath = Join-Path $testDir -ChildPath "testFiles"
+
+ # Path to specifically to that invalid test modules folder
+ $script:testModulesFolderPath = Join-Path $testFilesFolderPath -ChildPath "testModules"
+
+ # Path to specifically to that invalid test scripts folder
+ $script:testScriptsFolderPath = Join-Path $testFilesFolderPath -ChildPath "testScripts"
+
+ # Create test module with missing required module
+ CreateTestModule -Path $TestDrive -ModuleName 'ModuleWithMissingRequiredModule'
+ }
+ AfterAll {
+ Get-RevertPSResourceRepositoryFile
+ }
+ AfterEach {
+ # Delete all contents of the repository without deleting the repository directory itself
+ $pkgsToDelete = Join-Path -Path "$script:repositoryPath" -ChildPath "*"
+ Remove-Item $pkgsToDelete -Recurse
+
+ $pkgsToDelete = Join-Path -Path "$script:repositoryPath2" -ChildPath "*"
+ Remove-Item $pkgsToDelete -Recurse
+
+ $pkgsToDelete = Join-Path -Path $script:PublishModuleBase -ChildPath "*"
+ Remove-Item $pkgsToDelete -Recurse -ErrorAction SilentlyContinue
+ }
+
+ It "Publish a module with -Path and -Repository" {
+ $version = "1.0.0"
+ New-ModuleManifest -Path (Join-Path -Path $script:PublishModuleBase -ChildPath "$script:PublishModuleName.psd1") -ModuleVersion $version -Description "$script:PublishModuleName module"
+
+ Publish-Module -Path $script:PublishModuleBase -Repository $testRepository2 -verbose
+
+ $expectedPath = Join-Path -Path $script:repositoryPath2 -ChildPath "$script:PublishModuleName.$version.nupkg"
+ (Get-ChildItem $script:repositoryPath2).FullName | Should -Be $expectedPath
+ }
+
+
+ It "Publish a module with -Path pointing to a module directory (parent directory has same name)" {
+ $version = "1.0.0"
+ New-ModuleManifest -Path (Join-Path -Path $script:PublishModuleBase -ChildPath "$script:PublishModuleName.psd1") -ModuleVersion $version -Description "$script:PublishModuleName module"
+
+ Publish-Module -Path $script:PublishModuleBase -Repository $testRepository
+
+ $expectedPath = Join-Path -Path $script:repositoryPath -ChildPath "$script:PublishModuleName.$version.nupkg"
+ (Get-ChildItem $script:repositoryPath).FullName | Should -Be $expectedPath
+ }
+
+ It "Publish a module with -Path pointing to a module directory (parent directory has different name)" {
+ $version = "1.0.0"
+ $newModuleRoot = Join-Path -Path $script:PublishModuleBase -ChildPath "NewTestParentDirectory"
+ New-Item -Path $newModuleRoot -ItemType Directory
+ New-ModuleManifest -Path (Join-Path -Path $newModuleRoot -ChildPath "$script:PublishModuleName.psd1") -ModuleVersion $version -Description "$script:PublishModuleName module"
+
+ Publish-Module -Path $newModuleRoot -Repository $testRepository
+
+ $expectedPath = Join-Path -Path $script:repositoryPath -ChildPath "$script:PublishModuleName.$version.nupkg"
+ (Get-ChildItem $script:repositoryPath).FullName | Should -Be $expectedPath
+ }
+
+ It "Publish a module with -Path pointing to a .psd1 (parent directory has same name)" {
+ $version = "1.0.0"
+ $manifestPath = Join-Path -Path $script:PublishModuleBase -ChildPath "$script:PublishModuleName.psd1"
+ New-ModuleManifest -Path $manifestPath -ModuleVersion $version -Description "$script:PublishModuleName module"
+
+ Publish-Module -Path $manifestPath -Repository $testRepository
+
+ $expectedPath = Join-Path -Path $script:repositoryPath -ChildPath "$script:PublishModuleName.$version.nupkg"
+ (Get-ChildItem $script:repositoryPath).FullName | Should -Be $expectedPath
+ }
+
+ It "Publish a module with -Path pointing to a .psd1 (parent directory has different name)" {
+ $version = "1.0.0"
+ $newModuleRoot = Join-Path -Path $script:PublishModuleBase -ChildPath "NewTestParentDirectory"
+ New-Item -Path $newModuleRoot -ItemType Directory
+ $manifestPath = Join-Path -Path $newModuleRoot -ChildPath "$script:PublishModuleName.psd1"
+ New-ModuleManifest -Path $manifestPath -ModuleVersion $version -Description "$script:PublishModuleName module"
+
+ Publish-Module -Path $manifestPath -Repository $testRepository
+
+ $expectedPath = Join-Path -Path $script:repositoryPath -ChildPath "$script:PublishModuleName.$version.nupkg"
+ (Get-ChildItem $script:repositoryPath).FullName | Should -Be $expectedPath
+ }
+
+ It "Publish a module with dependencies" {
+ # Create dependency module
+ $dependencyVersion = "2.0.0"
+ New-ModuleManifest -Path (Join-Path -Path $script:DependencyModuleBase -ChildPath "$script:DependencyModuleName.psd1") -ModuleVersion $dependencyVersion -Description "$script:DependencyModuleName module"
+
+ Publish-Module -Path $script:DependencyModuleBase
+
+ # Create module to test
+ $version = "1.0.0"
+ New-ModuleManifest -Path (Join-Path -Path $script:PublishModuleBase -ChildPath "$script:PublishModuleName.psd1") -ModuleVersion $version -Description "$script:PublishModuleName module" -RequiredModules @(@{ModuleName = 'PackageManagement'; ModuleVersion = '2.0.0' })
+
+ Publish-Module -Path $script:PublishModuleBase
+
+ $nupkg = Get-ChildItem $script:repositoryPath | select-object -Last 1
+ $nupkg.Name | Should Be "$script:PublishModuleName.$version.nupkg"
+ }
+
+ It "Publish a module with a dependency that is not published, should throw" {
+ $version = "1.0.0"
+ $dependencyVersion = "2.0.0"
+ New-ModuleManifest -Path (Join-Path -Path $script:PublishModuleBase -ChildPath "$script:PublishModuleName.psd1") -ModuleVersion $version -Description "$script:PublishModuleName module" -RequiredModules @(@{ModuleName = 'PackageManagement'; ModuleVersion = '1.4.4' })
+
+ {Publish-Module -Path $script:PublishModuleBase -ErrorAction Stop} | Should -Throw -ErrorId "FindVersionFail,Microsoft.PowerShell.PowerShellGet.Cmdlets.PublishPSResource"
+ }
+
+ It "Publish a module and preserve file structure" {
+ $version = "1.0.0"
+ $testFile = Join-Path -Path "TestSubDirectory" -ChildPath "TestSubDirFile.ps1"
+ New-ModuleManifest -Path (Join-Path -Path $script:PublishModuleBase -ChildPath "$script:PublishModuleName.psd1") -ModuleVersion $version -Description "$script:PublishModuleName module"
+ New-Item -Path (Join-Path -Path $script:PublishModuleBase -ChildPath $testFile) -Force
+
+ Publish-Module -Path $script:PublishModuleBase
+
+ # Must change .nupkg to .zip so that Expand-Archive can work on Windows PowerShell
+ $nupkgPath = Join-Path -Path $script:repositoryPath -ChildPath "$script:PublishModuleName.$version.nupkg"
+ $zipPath = Join-Path -Path $script:repositoryPath -ChildPath "$script:PublishModuleName.$version.zip"
+ Rename-Item -Path $nupkgPath -NewName $zipPath
+ $unzippedPath = Join-Path -Path $TestDrive -ChildPath "$script:PublishModuleName"
+ New-Item $unzippedPath -Itemtype directory -Force
+ Expand-Archive -Path $zipPath -DestinationPath $unzippedPath
+
+ Test-Path -Path (Join-Path -Path $unzippedPath -ChildPath $testFile) | Should -Be $True
+ }
+
+ It "Publish a module to PSGallery without -APIKey, should throw" {
+ $version = "1.0.0"
+ New-ModuleManifest -Path (Join-Path -Path $script:PublishModuleBase -ChildPath "$script:PublishModuleName.psd1") -ModuleVersion $version -Description "$script:PublishModuleName module"
+
+ Publish-Module -Path $script:PublishModuleBase -Repository PSGallery -ErrorVariable ev -ErrorAction SilentlyContinue
+ $ev.FullyQualifiedErrorId | Should -be "APIKeyError,Microsoft.PowerShell.PowerShellGet.Cmdlets.PublishPSResource"
+ }
+
+ It "Publish a module to PSGallery using incorrect API key, should throw" {
+ $version = "1.0.0"
+ New-ModuleManifest -Path (Join-Path -Path $script:PublishModuleBase -ChildPath "$script:PublishModuleName.psd1") -ModuleVersion $version -Description "$script:PublishModuleName module"
+
+ Publish-Module -Path $script:PublishModuleBase -Repository PSGallery -NuGetApiKey "123456789" -ErrorAction SilentlyContinue
+
+ $Error[0].FullyQualifiedErrorId | Should -be "403Error,Microsoft.PowerShell.PowerShellGet.Cmdlets.PublishPSResource"
+ }
+
+ It "publish a script locally"{
+ $scriptName = "PSGetTestScript"
+ $scriptVersion = "1.0.0"
+
+ $params = @{
+ Version = $scriptVersion
+ GUID = [guid]::NewGuid()
+ Author = 'Jane'
+ CompanyName = 'Microsoft Corporation'
+ Copyright = '(c) 2020 Microsoft Corporation. All rights reserved.'
+ Description = "Description for the $scriptName script"
+ LicenseUri = "https://$scriptName.com/license"
+ IconUri = "https://$scriptName.com/icon"
+ ProjectUri = "https://$scriptName.com"
+ Tags = @('Tag1','Tag2', "Tag-$scriptName-$scriptVersion")
+ ReleaseNotes = "$scriptName release notes"
+ }
+
+ $scriptPath = (Join-Path -Path $script:tmpScriptsFolderPath -ChildPath "$scriptName.ps1")
+ New-PSScriptFileInfo @params -Path $scriptPath
+
+ Publish-Script -Path $scriptPath
+
+ $expectedPath = Join-Path -Path $script:repositoryPath -ChildPath "$scriptName.$scriptVersion.nupkg"
+ (Get-ChildItem $script:repositoryPath).FullName | Should -Be $expectedPath
+ }
+
+ It "should publish a script without lines in between comment blocks locally" {
+ $scriptName = "ScriptWithoutEmptyLinesBetweenCommentBlocks"
+ $scriptVersion = "1.0.0"
+ $scriptPath = (Join-Path -Path $script:testScriptsFolderPath -ChildPath "$scriptName.ps1")
+
+ Publish-Script -Path $scriptPath
+
+ $expectedPath = Join-Path -Path $script:repositoryPath -ChildPath "$scriptName.$scriptVersion.nupkg"
+ (Get-ChildItem $script:repositoryPath).FullName | Should -Be $expectedPath
+ }
+
+ It "should publish a script without lines in help block locally" {
+ $scriptName = "ScriptWithoutEmptyLinesInMetadata"
+ $scriptVersion = "1.0.0"
+ $scriptPath = (Join-Path -Path $script:testScriptsFolderPath -ChildPath "$scriptName.ps1")
+
+ Publish-Script -Path $scriptPath
+
+ $expectedPath = Join-Path -Path $script:repositoryPath -ChildPath "$scriptName.$scriptVersion.nupkg"
+ (Get-ChildItem $script:repositoryPath).FullName | Should -Be $expectedPath
+ }
+
+ It "should write error and not publish script when Author property is missing" {
+ $scriptName = "InvalidScriptMissingAuthor.ps1"
+ $scriptVersion = "1.0.0"
+
+ $scriptFilePath = Join-Path $script:testScriptsFolderPath -ChildPath $scriptName
+ Publish-Script -Path $scriptFilePath -ErrorVariable err -ErrorAction SilentlyContinue
+ $err.Count | Should -BeGreaterThan 0
+ $err[0].FullyQualifiedErrorId | Should -BeExactly "psScriptMissingAuthor,Microsoft.PowerShell.PowerShellGet.Cmdlets.PublishPSResource"
+
+ $publishedPath = Join-Path -Path $script:repositoryPath -ChildPath "$scriptName.$scriptVersion.nupkg"
+ Test-Path -Path $publishedPath | Should -Be $false
+ }
+
+ It "should write error and not publish script when Version property is missing" {
+ $scriptName = "InvalidScriptMissingVersion.ps1"
+
+ $scriptFilePath = Join-Path $script:testScriptsFolderPath -ChildPath $scriptName
+ Publish-Script -Path $scriptFilePath -ErrorVariable err -ErrorAction SilentlyContinue
+ $err.Count | Should -BeGreaterThan 0
+ $err[0].FullyQualifiedErrorId | Should -BeExactly "psScriptMissingVersion,Microsoft.PowerShell.PowerShellGet.Cmdlets.PublishPSResource"
+
+ $publishedPkgs = Get-ChildItem -Path $script:repositoryPath -Filter *.nupkg
+ $publishedPkgs | Should -HaveCount 0
+ }
+
+
+ It "should write error and not publish script when Guid property is missing" {
+ $scriptName = "InvalidScriptMissingGuid.ps1"
+ $scriptVersion = "1.0.0"
+
+ $scriptFilePath = Join-Path $script:testScriptsFolderPath -ChildPath $scriptName
+ Publish-Script -Path $scriptFilePath -ErrorVariable err -ErrorAction SilentlyContinue
+ $err.Count | Should -BeGreaterThan 0
+ $err[0].FullyQualifiedErrorId | Should -BeExactly "psScriptMissingGuid,Microsoft.PowerShell.PowerShellGet.Cmdlets.PublishPSResource"
+
+ $publishedPath = Join-Path -Path $script:repositoryPath -ChildPath "$scriptName.$scriptVersion.nupkg"
+ Test-Path -Path $publishedPath | Should -Be $false
+ }
+
+ It "should write error and not publish script when Description property is missing" {
+ $scriptName = "InvalidScriptMissingDescription.ps1"
+ $scriptVersion = "1.0.0"
+
+ $scriptFilePath = Join-Path $script:testScriptsFolderPath -ChildPath $scriptName
+ Publish-Script -Path $scriptFilePath -ErrorVariable err -ErrorAction SilentlyContinue
+ $err.Count | Should -BeGreaterThan 0
+ $err[0].FullyQualifiedErrorId | Should -BeExactly "PSScriptInfoMissingDescription,Microsoft.PowerShell.PowerShellGet.Cmdlets.PublishPSResource"
+
+ $publishedPath = Join-Path -Path $script:repositoryPath -ChildPath "$scriptName.$scriptVersion.nupkg"
+ Test-Path -Path $publishedPath | Should -Be $false
+ }
+
+ It "should write error and not publish script when Description block altogether is missing" {
+ # we expect .ps1 files to have a separate comment block for .DESCRIPTION property, not to be included in the PSScriptInfo commment block
+ $scriptName = "InvalidScriptMissingDescriptionCommentBlock.ps1"
+ $scriptVersion = "1.0.0"
+
+ $scriptFilePath = Join-Path $script:testScriptsFolderPath -ChildPath $scriptName
+ Publish-Script -Path $scriptFilePath -ErrorVariable err -ErrorAction SilentlyContinue
+ $err.Count | Should -BeGreaterThan 0
+ $err[0].FullyQualifiedErrorId | Should -BeExactly "missingHelpInfoCommentError,Microsoft.PowerShell.PowerShellGet.Cmdlets.PublishPSResource"
+
+ $publishedPath = Join-Path -Path $script:repositoryPath -ChildPath "$scriptName.$scriptVersion.nupkg"
+ Test-Path -Path $publishedPath | Should -Be $false
+ }
+
+ It "Publish a module with that has an invalid version format, should throw" {
+ $moduleName = "incorrectmoduleversion"
+ $incorrectmoduleversion = Join-Path -Path $script:testModulesFolderPath -ChildPath $moduleName
+
+ {Publish-Module -Path $incorrectmoduleversion -ErrorAction Stop} | Should -Throw -ErrorId "InvalidModuleManifest,Microsoft.PowerShell.PowerShellGet.Cmdlets.PublishPSResource"
+ }
+
+ It "Publish a module with a dependency that has an invalid version format, should throw" {
+ $moduleName = "incorrectdepmoduleversion"
+ $incorrectdepmoduleversion = Join-Path -Path $script:testModulesFolderPath -ChildPath $moduleName
+
+ {Publish-Module -Path $incorrectdepmoduleversion -ErrorAction Stop} | Should -Throw -ErrorId "InvalidModuleManifest,Microsoft.PowerShell.PowerShellGet.Cmdlets.PublishPSResource"
+ }
+}
+
+# Ensure that PSGet v2 was not loaded during the test via command discovery
+$PSGetVersionsLoaded = (Get-Module powershellget).Version
+Write-Host "PowerShellGet versions currently loaded: $PSGetVersionsLoaded"
+if ($PSGetVersionsLoaded.Count -gt 1) {
+ throw "There was more than one version of PowerShellGet imported into the current session. `
+ Imported versions include: $PSGetVersionsLoaded"
+}
\ No newline at end of file
diff --git a/Test/RegisterPSResourceRepository.Tests.ps1 b/Test/RegisterPSResourceRepository.Tests.ps1
new file mode 100644
index 0000000..e127475
--- /dev/null
+++ b/Test/RegisterPSResourceRepository.Tests.ps1
@@ -0,0 +1,171 @@
+# Copyright (c) Microsoft Corporation.
+# Licensed under the MIT License.
+
+$modPath = "$psscriptroot/../PSGetTestUtils.psm1"
+Import-Module $modPath -Force -Verbose
+Write-Verbose -Verbose -Message "PowerShellGet version currently loaded: $($(Get-Module powershellget).Version)"
+
+Describe "Test CompatPowerShellGet: Register-PSResourceRepository" -tags 'CI' {
+ BeforeEach {
+ $PSGalleryName = Get-PSGalleryName
+ $PSGalleryUri = Get-PSGalleryLocation
+ $TestRepoName1 = "testRepository"
+ $TestRepoName2 = "testRepository2"
+ $TestRepoName3 = "testRepository3"
+ $TestRepoName4 = "testRepository4"
+ $relativeCurrentPath = Get-Location
+ Get-NewPSResourceRepositoryFile
+ $tmpDir1Path = Join-Path -Path $TestDrive -ChildPath "tmpDir1"
+ $tmpDir2Path = Join-Path -Path $TestDrive -ChildPath "tmpDir2"
+ $tmpDir3Path = Join-Path -Path $TestDrive -ChildPath "tmpDir3"
+ $tmpDir4Path = Join-Path -Path $TestDrive -ChildPath "tmpDir4"
+ $tmpDirPaths = @($tmpDir1Path, $tmpDir2Path, $tmpDir3Path, $tmpDir4Path)
+ Get-NewTestDirs($tmpDirPaths)
+
+ $relativeCurrentPath = Get-Location
+
+ $randomSecret = [System.IO.Path]::GetRandomFileName()
+ $randomPassword = [System.IO.Path]::GetRandomFileName()
+
+ $credentialInfo1 = New-Object Microsoft.PowerShell.PowerShellGet.UtilClasses.PSCredentialInfo ("testvault", $randomSecret)
+ $secureString = ConvertTo-SecureString $randomPassword -AsPlainText -Force
+ $credential = New-Object pscredential ("testusername", $secureString)
+ $credentialInfo2 = New-Object Microsoft.PowerShell.PowerShellGet.UtilClasses.PSCredentialInfo ("testvault", $randomSecret, $credential)
+ }
+ AfterEach {
+ Get-RevertPSResourceRepositoryFile
+ $tmpDir1Path = Join-Path -Path $TestDrive -ChildPath "tmpDir1"
+ $tmpDir2Path = Join-Path -Path $TestDrive -ChildPath "tmpDir2"
+ $tmpDir3Path = Join-Path -Path $TestDrive -ChildPath "tmpDir3"
+ $tmpDir4Path = Join-Path -Path $TestDrive -ChildPath "tmpDir4"
+ $tmpDirPaths = @($tmpDir1Path, $tmpDir2Path, $tmpDir3Path, $tmpDir4Path)
+ Get-RemoveTestDirs($tmpDirPaths)
+ }
+
+ It "register repository given Name, SourceLocation (bare minimum for NameParmaterSet)" {
+ Register-PSRepository -Name $TestRepoName1 -SourceLocation $tmpDir1Path
+ $res = Get-PSResourceRepository -Name $TestRepoName1
+ $res.Name | Should -Be $TestRepoName1
+ $Res.Uri.LocalPath | Should -Contain $tmpDir1Path
+ $res.Trusted | Should -Be False
+ }
+
+ It "register repository with Name, Uri, Trusted (NameParameterSet)" {
+ Register-PSRepository -Name $TestRepoName1 -SourceLocation $tmpDir1Path -InstallationPolicy Trusted
+ $res = Get-PSResourceRepository -Name $TestRepoName1
+ $res.Name | Should -Be $TestRepoName1
+ $Res.Uri.LocalPath | Should -Contain $tmpDir1Path
+ $res.Trusted | Should -Be True
+ }
+
+ It "register repository with PSGallery parameter (PSGalleryParameterSet)" {
+ Unregister-PSResourceRepository -Name $PSGalleryName
+ Register-PSRepository -Default
+ $res = Get-PSResourceRepository -Name $PSGalleryName
+ $res.Name | Should -Be $PSGalleryName
+ $res.Uri | Should -Be $PSGalleryUri
+ $res.Trusted | Should -Be False
+ }
+
+ It "register repository with PSGallery, InstallationPolicy parameters (PSGalleryParameterSet)" {
+ Unregister-PSResourceRepository -Name $PSGalleryName
+ Register-PSRepository -Default -InstallationPolicy Trusted
+ $res = Get-PSResourceRepository -Name $PSGalleryName
+ $res.Name | Should -Be $PSGalleryName
+ $res.Uri | Should -Be $PSGalleryUri
+ $res.Trusted | Should -Be True
+ }
+
+ It "not register repository when Name is provided but -SourceLocation is not" {
+ {Register-PSRepository -Name $TestRepoName1 -SourceLocation "" -ErrorAction Stop} | Should -Throw -ErrorId "ParameterArgumentValidationError,Microsoft.PowerShell.PowerShellGet.Cmdlets.RegisterPSResourceRepository"
+ }
+
+ It "not register repository when Name is empty but -SourceLocation is provided" {
+ {Register-PSRepository -Name "" -SourceLocation $tmpDir1Path -ErrorAction Stop} | Should -Throw -ErrorId "ParameterArgumentValidationError,Register-PSRepository"
+ }
+
+ It "not register repository when Name is null but -SourceLocation is provided" {
+ {Register-PSRepository -Name $null -SourceLocation $tmpDir1Path -ErrorAction Stop} | Should -Throw -ErrorId "ParameterArgumentValidationError,Register-PSRepository"
+ }
+
+ It "not register repository when Name is just whitespace but -SourceLocation is provided" {
+ {Register-PSRepository -Name " " -SourceLocation $tmpDir1Path -ErrorAction Stop} | Should -Throw -ErrorId "ErrorInNameParameterSet,Microsoft.PowerShell.PowerShellGet.Cmdlets.RegisterPSResourceRepository"
+ }
+
+ It "not register PSGallery with NameParameterSet" {
+ {Register-PSRepository -Name $PSGalleryName -SourceLocation $PSGalleryUri -ErrorAction Stop} | Should -Throw -ErrorId "ErrorInNameParameterSet,Microsoft.PowerShell.PowerShellGet.Cmdlets.RegisterPSResourceRepository"
+ }
+
+ # this error message comes from the parameter cmdlet tags (earliest point of detection)
+ It "not register PSGallery when PSGallery parameter provided with Name, Uri or CredentialInfo" {
+ {Register-PSRepository -PSGallery -Name $PSGalleryName -ErrorAction Stop} | Should -Throw -ErrorId "NamedParameterNotFound,Register-PSRepository"
+ {Register-PSRepository -PSGallery -SourceLocation $PSGalleryUri -ErrorAction Stop} | Should -Throw -ErrorId "NamedParameterNotFound,Register-PSRepository"
+ }
+
+ It "should register repository with relative location provided as Uri" {
+ Register-PSRepository -Name $TestRepoName1 -SourceLocation ".\"
+ $res = Get-PSResourceRepository -Name $TestRepoName1
+
+ $res.Name | Should -Be $TestRepoName1
+ $Res.Uri.LocalPath | Should -Contain $relativeCurrentPath
+ $res.Trusted | Should -Be False
+ $res.Priority | Should -Be 50
+ }
+
+ It "should register local file share NuGet based repository" {
+ Register-PSRepository -Name "localFileShareTestRepo" -SourceLocation "\\hcgg.rest.of.domain.name\test\ITxx\team\NuGet\"
+ $res = Get-PSResourceRepository -Name "localFileShareTestRepo"
+
+ $res.Name | Should -Be "localFileShareTestRepo"
+ $res.Uri.LocalPath | Should -Contain "\\hcgg.rest.of.domain.name\test\ITxx\team\NuGet\"
+ }
+
+ It 'Register-PSRepository File system location with special chars' {
+ $tmpdir = Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath 'ps repo testing [$!@^&test(;)]'
+ if (-not (Test-Path -LiteralPath $tmpdir)) {
+ New-Item -Path $tmpdir -ItemType Directory > $null
+ }
+ try {
+ Register-PSRepository -Name 'Test Repo' -SourceLocation $tmpdir
+ try {
+ $repo = Get-PSRepository -Name 'Test Repo'
+ $repo.Name | Should -Be 'Test Repo'
+ $repo.Uri.ToString().EndsWith('ps repo testing [$!@^&test(;)]') | should be $true
+ }
+ finally {
+ Unregister-PSRepository -Name 'Test Repo' -ErrorAction SilentlyContinue
+ }
+ }
+ finally {
+ Remove-Item -LiteralPath $tmpdir -Force -Recurse
+ }
+ }
+
+ It 'Reregister PSGallery again: Should fail' {
+ { Register-PSRepository -Default -ErrorVariable ev -ErrorAction SilentlyContinue } | Should Throw 'Adding to repository store failed: The PSResource Repository 'PSGallery' already exists'
+ }
+
+ It 'Register-PSRepository -Name PSGallery -SourceLocation $SourceLocation : Should fail' {
+ { Register-PSRepository $RepositoryName $SourceLocation -ErrorVariable ev -ErrorAction SilentlyContinue } | Should Throw "Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again."
+ }
+
+ It 'Register-PSRepository -Name PSGallery -SourceLocation $SourceLocation -PublishLocation $PublishLocation : Should fail' {
+ { Register-PSRepository $RepositoryName $SourceLocation -PublishLocation $PublishLocation -ErrorVariable ev -ErrorAction SilentlyContinue } | Should Throw "Cannot validate argument on parameter 'PublishLocation'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again."
+ }
+
+ It 'Register-PSRepository -Name PSGallery -SourceLocation $SourceLocation -ScriptPublishLocation $ScriptPublishLocation : Should fail' {
+ { Register-PSRepository -Name $RepositoryName $SourceLocation -ScriptPublishLocation $ScriptPublishLocation -ErrorVariable ev -ErrorAction SilentlyContinue } | Should Throw "Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again."
+ }
+
+ It 'Register-PSRepository -Name PSGallery -SourceLocation $SourceLocation -ScriptSourceLocation $ScriptSourceLocation : Should fail' {
+ { Register-PSRepository $RepositoryName -SourceLocation $SourceLocation -ScriptSourceLocation $ScriptSourceLocation -ErrorVariable ev -ErrorAction SilentlyContinue } | Should Throw "Cannot validate argument on parameter 'SourceLocation'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again."
+ }
+}
+
+# Ensure that PSGet v2 was not loaded during the test via command discovery
+$PSGetVersionsLoaded = (Get-Module powershellget).Version
+Write-Host "PowerShellGet versions currently loaded: $PSGetVersionsLoaded"
+if ($PSGetVersionsLoaded.Count -gt 1) {
+ throw "There was more than one version of PowerShellGet imported into the current session. `
+ Imported versions include: $PSGetVersionsLoaded"
+}
\ No newline at end of file
diff --git a/Test/SavePSResource.Tests.ps1 b/Test/SavePSResource.Tests.ps1
new file mode 100644
index 0000000..1785b30
--- /dev/null
+++ b/Test/SavePSResource.Tests.ps1
@@ -0,0 +1,159 @@
+# Copyright (c) Microsoft Corporation.
+# Licensed under the MIT License.
+
+$ProgressPreference = "SilentlyContinue"
+$modPath = "$psscriptroot/../PSGetTestUtils.psm1"
+Write-Verbose -Verbose -Message "PowerShellGet version currently loaded: $($(Get-Module powershellget).Version)"
+
+Describe 'Test CompatPowerShellGet: Save-PSResource' -tags 'CI' {
+
+ BeforeAll {
+ $PSGalleryName = Get-PSGalleryName
+ $testModuleName = "test_module"
+ $testScriptName = "test_script"
+ $testModuleName2 = "testmodule99"
+ $PackageManagement = "PackageManagement"
+ Get-NewPSResourceRepositoryFile
+ Set-PSResourceRepository -Name PSGallery -Trusted
+
+ $SaveDir = Join-Path $TestDrive 'SavedResources'
+ New-Item -Item Directory $SaveDir -Force
+ }
+
+ AfterEach {
+ # Delete contents of save directory
+ Remove-Item -Path (Join-Path $SaveDir '*') -Recurse -Force -ErrorAction SilentlyContinue
+ }
+
+ AfterAll {
+ Get-RevertPSResourceRepositoryFile
+ }
+
+ It "Save-Module with Find-DscResource output" {
+ $DscResourceName = 'SystemLocale'
+ $ModuleName = 'SystemLocaleDsc'
+ $res1 = Find-DscResource -Name $DscResourceName
+ $res1 | Should -Not -BeNullOrEmpty
+
+ Find-DscResource -Name $DscResourceName | Save-Module -Path $SaveDir
+
+ $pkgDirs = Get-ChildItem -Path $SaveDir | Where-Object { $_.Name -eq $ModuleName }
+ $pkgDirs | Should -HaveCount 1
+ }
+
+ It "Save-Module with Find-Command output" {
+ $cmdName = "Get-WUJob"
+ $ModuleName = "PSWindowsUpdate"
+ $res1 = Find-Command -Name $cmdName
+ $res1 | Should -Not -BeNullOrEmpty
+
+ Find-Command -Name $cmdName | Save-Module -Path $SaveDir
+
+ $pkgDirs = Get-ChildItem -Path $SaveDir | Where-Object { $_.Name -eq $ModuleName }
+ $pkgDirs | Should -HaveCount 1
+ }
+
+ It "Save-Module with dependencies" {
+ $ModuleName = "test_module"
+ $dependency1 = "RequiredModule1"
+ $dependency2 = "RequiredModule2"
+ $dependency3 = "RequiredModule3"
+ $dependency4 = "RequiredModule4"
+ $dependency5 = "RequiredModule5"
+
+ Save-Module -Name $ModuleName -Repository PSGallery -Path $SaveDir
+
+ $pkgDirs = Get-ChildItem -Path $SaveDir | Where-Object { $_.Name -eq $ModuleName -or $dependency1 -or $dependency2 -or $dependency3 -or $dependency4 -or $dependency5 }
+ $pkgDirs.Count | Should -BeGreaterOrEqual 6
+ }
+
+ It "Save-Module with Find-Module output" {
+ Find-PSResource -Name $testModuleName2 -Repository PSGallery | Save-Module -Path $SaveDir
+
+ $pkgDirs = Get-ChildItem -Path $SaveDir | Where-Object { $_.Name -eq $testModuleName2 }
+ $pkgDirs | Should -HaveCount 1
+ }
+
+ It "Save specific module resource by name" {
+ Save-Module -Name $testModuleName2 -Repository $PSGalleryName -Path $SaveDir
+ $pkgDir = Get-ChildItem -Path $SaveDir | Where-Object Name -eq $testModuleName2
+ $pkgDir | Should -Not -BeNullOrEmpty
+ (Get-ChildItem $pkgDir.FullName).Count | Should -HaveCount 1
+ }
+
+ It "Save specific script resource by name" {
+ Save-Script -Name $testScriptName -Repository $PSGalleryName -Path $SaveDir
+ $pkgDir = Get-ChildItem -Path $SaveDir | Where-Object Name -eq "$testScriptName.ps1"
+ $pkgDir | Should -Not -BeNullOrEmpty
+ (Get-ChildItem $pkgDir.FullName).Count | Should -HaveCount 1
+ }
+
+ It "Save multiple resources by name" {
+ $pkgNames = @($testModuleName, $testModuleName2)
+ Save-Module -Name $pkgNames -Repository $PSGalleryName -Path $SaveDir
+ $pkgDirs = Get-ChildItem -Path $SaveDir | Where-Object { $_.Name -eq $testModuleName -or $_.Name -eq $testModuleName2 }
+ $pkgDirs | Should -HaveCount 2
+ (Get-ChildItem $pkgDirs[0].FullName) | Should -HaveCount 1
+ (Get-ChildItem $pkgDirs[1].FullName) | Should -HaveCount 1
+ }
+
+ It "Should not save resource given nonexistant name" {
+ Save-Module -Name NonExistentModule -Repository $PSGalleryName -Path $SaveDir -ErrorVariable err -ErrorAction SilentlyContinue
+ $pkgDir = Get-ChildItem -Path $SaveDir | Where-Object Name -eq "NonExistentModule"
+ $pkgDir.Name | Should -BeNullOrEmpty
+ }
+
+ It "Not Save module with Name containing wildcard" {
+ Save-Module -Name "TestModule*" -Repository $PSGalleryName -Path $SaveDir -ErrorVariable err -ErrorAction SilentlyContinue
+ $err.Count | Should -BeGreaterThan 0
+ $err[0].FullyQualifiedErrorId | Should -BeExactly "NameContainsWildcard,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource"
+ }
+
+ It "Should save resource given name and exact version" {
+ Save-Module -Name $testModuleName2 -RequiredVersion "0.0.2" -Repository $PSGalleryName -Path $SaveDir
+ $pkgDir = Get-ChildItem -Path $SaveDir | Where-Object Name -eq $testModuleName2
+ $pkgDir | Should -Not -BeNullOrEmpty
+ $pkgDirVersion = Get-ChildItem $pkgDir.FullName
+ $pkgDirVersion.Name | Should -Be "0.0.2"
+ }
+
+ It "Save resource with latest (including prerelease) version given Prerelease parameter" {
+ Save-Module -Name $testModuleName2 -AllowPrerelease -Repository $PSGalleryName -Path $SaveDir
+ $pkgDir = Get-ChildItem -Path $SaveDir | Where-Object Name -eq $testModuleName2
+ $pkgDir | Should -Not -BeNullOrEmpty
+ $pkgDirVersion = Get-ChildItem -Path $pkgDir.FullName
+ $pkgDirVersion.Name | Should -Be "1.0.0"
+ }
+
+ It "Save a module with a dependency" {
+ Save-Module -Name "TestModuleWithDependencyE" -RequiredVersion "1.0.0.0" -Repository $PSGalleryName -Path $SaveDir
+ $pkgDirs = Get-ChildItem -Path $SaveDir | Where-Object { $_.Name -eq "TestModuleWithDependencyE" -or $_.Name -eq "TestModuleWithDependencyC" -or $_.Name -eq "TestModuleWithDependencyB" -or $_.Name -eq "TestModuleWithDependencyD"}
+ $pkgDirs.Count | Should -BeGreaterThan 1
+ (Get-ChildItem $pkgDirs[0].FullName).Count | Should -BeGreaterThan 0
+ (Get-ChildItem $pkgDirs[1].FullName).Count | Should -BeGreaterThan 0
+ (Get-ChildItem $pkgDirs[2].FullName).Count | Should -BeGreaterThan 0
+ (Get-ChildItem $pkgDirs[3].FullName).Count | Should -BeGreaterThan 0
+ }
+
+ It "Save a module with a dependency and skip saving the dependency" {
+ Save-Module -Name "TestModuleWithDependencyE" -RequiredVersion "1.0.0.0" -Repository $PSGalleryName -Path $SaveDir
+ $pkgDirs = Get-ChildItem -Path $SaveDir | Where-Object { $_.Name -eq "TestModuleWithDependencyE"}
+ $pkgDirs | Should -HaveCount 1
+ (Get-ChildItem $pkgDirs[0].FullName) | Should -HaveCount 1
+ }
+
+ It "Save PSResourceInfo object piped in for prerelease version object" -Pending {
+ Find-PSResource -Name $testModuleName -Version "5.2.5-alpha001" -Repository $PSGalleryName | Save-Module -Path $SaveDir
+ $pkgDir = Get-ChildItem -Path $SaveDir | Where-Object Name -eq $testModuleName
+ $pkgDir | Should -Not -BeNullOrEmpty
+ (Get-ChildItem -Path $pkgDir.FullName) | Should -HaveCount 1
+ }
+}
+
+# Ensure that PSGet v2 was not loaded during the test via command discovery
+$PSGetVersionsLoaded = (Get-Module powershellget).Version
+Write-Host "PowerShellGet versions currently loaded: $PSGetVersionsLoaded"
+if ($PSGetVersionsLoaded.Count -gt 1) {
+ throw "There was more than one version of PowerShellGet imported into the current session. `
+ Imported versions include: $PSGetVersionsLoaded"
+}
\ No newline at end of file
diff --git a/Test/SetPSResourceRepository.ps1 b/Test/SetPSResourceRepository.ps1
new file mode 100644
index 0000000..0395fe9
--- /dev/null
+++ b/Test/SetPSResourceRepository.ps1
@@ -0,0 +1,122 @@
+# Copyright (c) Microsoft Corporation.
+# Licensed under the MIT License.
+
+$modPath = "$psscriptroot/../PSGetTestUtils.psm1"
+Import-Module $modPath -Force -Verbose
+Write-Verbose -Verbose -Message "PowerShellGet version currently loaded: $($(Get-Module powershellget).Version)"
+
+Describe "Test CompatPowerShellGet: Set-PSResourceRepository" -tags 'CI' {
+ BeforeEach {
+ $PSGalleryName = Get-PSGalleryName
+ $PSGalleryUri = Get-PSGalleryLocation
+ $TestRepoName1 = "testRepository"
+ $TestRepoName2 = "testRepository2"
+ $TestRepoName3 = "testRepository3"
+ $relativeCurrentPath = Get-Location
+ Get-NewPSResourceRepositoryFile
+ $tmpDir1Path = Join-Path -Path $TestDrive -ChildPath "tmpDir1"
+ $tmpDir2Path = Join-Path -Path $TestDrive -ChildPath "tmpDir2"
+ $tmpDir3Path = Join-Path -Path $TestDrive -ChildPath "tmpDir3"
+ $tmpDir4Path = Join-Path -Path $TestDrive -ChildPath "tmpDir4"
+ $tmpDirPaths = @($tmpDir1Path, $tmpDir2Path, $tmpDir3Path, $tmpDir4Path)
+ Get-NewTestDirs($tmpDirPaths)
+
+ $relativeCurrentPath = Get-Location
+
+ $randomSecret = [System.IO.Path]::GetRandomFileName()
+ $randomPassword = [System.IO.Path]::GetRandomFileName()
+
+ $credentialInfo1 = New-Object Microsoft.PowerShell.PowerShellGet.UtilClasses.PSCredentialInfo ("testvault", $randomSecret)
+ $secureString = ConvertTo-SecureString $randomPassword -AsPlainText -Force
+ $credential = New-Object pscredential ("testusername", $secureString)
+ $credentialInfo2 = New-Object Microsoft.PowerShell.PowerShellGet.UtilClasses.PSCredentialInfo ("testvault", $randomSecret, $credential)
+ }
+ AfterEach {
+ Get-RevertPSResourceRepositoryFile
+ $tmpDir1Path = Join-Path -Path $TestDrive -ChildPath "tmpDir1"
+ $tmpDir2Path = Join-Path -Path $TestDrive -ChildPath "tmpDir2"
+ $tmpDir3Path = Join-Path -Path $TestDrive -ChildPath "tmpDir3"
+ $tmpDir4Path = Join-Path -Path $TestDrive -ChildPath "tmpDir4"
+ $tmpDirPaths = @($tmpDir1Path, $tmpDir2Path, $tmpDir3Path, $tmpDir4Path)
+ Get-RemoveTestDirs($tmpDirPaths)
+ }
+
+ It "set repository given Name and SourceLocation parameters" {
+ Register-PSResourceRepository -Name $TestRepoName1 -Uri $tmpDir1Path
+ Set-PSRepository -Name $TestRepoName1 -SourceLocation $tmpDir2Path
+ $res = Get-PSResourceRepository -Name $TestRepoName1
+ $res.Name | Should -Be $TestRepoName1
+ $Res.Uri.LocalPath | Should -Contain $tmpDir2Path
+ $res.Trusted | Should -Be False
+ }
+
+ It "set repository given Name and Trusted parameters" {
+ Register-PSResourceRepository -Name $TestRepoName1 -Uri $tmpDir1Path
+ Set-PSRepository -Name $TestRepoName1 -InstallationPolicy Trusted
+ $res = Get-PSResourceRepository -Name $TestRepoName1
+ $res.Name | Should -Be $TestRepoName1
+ $Res.Uri.LocalPath | Should -Contain $tmpDir1Path
+ $res.Trusted | Should -Be True
+ }
+
+ It "set repository given pipeline input ValueFromPipelineByPropertyName passed in" {
+ Register-PSResourceRepository -Name $TestRepoName1 -Uri $tmpDir1Path
+ Get-PSResourceRepository -Name $TestRepoName1 | Set-PSRepository -InstallationPolicy Trusted
+ $res = Get-PSResourceRepository -Name $TestRepoName1
+ $res.Name | Should -Be $TestRepoName1
+ $Res.Uri.LocalPath | Should -Contain $tmpDir1Path
+ $res.Trusted | Should -Be True
+ }
+
+ It "not set repository and write error given just Name parameter" {
+ Register-PSResourceRepository -Name $TestRepoName1 -Uri $tmpDir1Path
+ {Set-PSRepository -Name $TestRepoName1 -ErrorAction Stop} | Should -Throw -ErrorId "ErrorInNameParameterSet,Microsoft.PowerShell.PowerShellGet.Cmdlets.SetPSResourceRepository"
+ }
+
+ It "not set repository and throw error given Name contains * (NameParameterSet)" {
+ Register-PSResourceRepository -Name $TestRepoName1 -Uri $tmpDir1Path
+ {Set-PSRepository -Name "test*Repository" -ErrorAction Stop} | Should -Throw -ErrorId "ErrorInNameParameterSet,Microsoft.PowerShell.PowerShellGet.Cmdlets.SetPSResourceRepository"
+ }
+
+ It "not set repository and throw error given Name is null (NameParameterSet)" {
+ Register-PSResourceRepository -Name $TestRepoName1 -Uri $tmpDir1Path
+ {Set-PSRepository -Name $null -ErrorAction Stop} | Should -Throw -ErrorId "ParameterArgumentValidationError,Set-PSRepository"
+ }
+
+ It "not set repository and throw error given Name is whitespace (NameParameterSet)" {
+ Register-PSResourceRepository -Name $TestRepoName1 -Uri $tmpDir1Path
+ {Set-PSRepository -Name " " -ErrorAction Stop} | Should -Throw -ErrorId "ErrorInNameParameterSet,Microsoft.PowerShell.PowerShellGet.Cmdlets.SetPSResourceRepository"
+ }
+
+ It "not set and throw error for trying to set PSGallery Uri (NameParameterSet)" {
+ Unregister-PSResourceRepository -Name $PSGalleryName
+ Register-PSResourceRepository -PSGallery
+ {Set-PSRepository -Name $PSGalleryName -SourceLocation $tmpDir1Path -ErrorAction Stop} | Should -Throw -ErrorId "ErrorInNameParameterSet,Microsoft.PowerShell.PowerShellGet.Cmdlets.SetPSResourceRepository"
+ }
+
+ It "should set repository with relative Uri provided" {
+ Register-PSResourceRepository -Name $TestRepoName1 -Uri $tmpDir1Path
+ Set-PSRepository -Name $TestRepoName1 -SourceLocation $relativeCurrentPath.ToString()
+ $res = Get-PSResourceRepository -Name $TestRepoName1
+ $res.Name | Should -Be $TestRepoName1
+ $reformattedPath = ($relativeCurrentPath -replace "\\", "/")
+ $res.Uri.ToString().Contains($reformattedPath) | Should -Be $true
+ $res.Trusted | Should -Be False
+ }
+
+ It "should set repository with local file share NuGet based Uri" {
+ Register-PSResourceRepository -Name "localFileShareTestRepo" -Uri $tmpDir1Path
+ Set-PSRepository -Name "localFileShareTestRepo" -SourceLocation "\\hcgg.rest.of.domain.name\test\ITxx\team\NuGet\"
+ $res = Get-PSResourceRepository -Name "localFileShareTestRepo"
+ $res.Name | Should -Be "localFileShareTestRepo"
+ $Res.Uri | Should -Contain "\\hcgg.rest.of.domain.name\test\ITxx\team\NuGet\"
+ }
+}
+
+# Ensure that PSGet v2 was not loaded during the test via command discovery
+$PSGetVersionsLoaded = (Get-Module powershellget).Version
+Write-Host "PowerShellGet versions currently loaded: $PSGetVersionsLoaded"
+if ($PSGetVersionsLoaded.Count -gt 1) {
+ throw "There was more than one version of PowerShellGet imported into the current session. `
+ Imported versions include: $PSGetVersionsLoaded"
+}
\ No newline at end of file
diff --git a/Test/TestPSScriptFile.Tests.ps1 b/Test/TestPSScriptFile.Tests.ps1
new file mode 100644
index 0000000..f0d49c5
--- /dev/null
+++ b/Test/TestPSScriptFile.Tests.ps1
@@ -0,0 +1,88 @@
+# Copyright (c) Microsoft Corporation.
+# Licensed under the MIT License.
+
+$modPath = "$psscriptroot/../PSGetTestUtils.psm1"
+Import-Module $modPath -Force -Verbose
+Write-Verbose -Verbose -Message "PowerShellGet version currently loaded: $($(Get-Module powershellget).Version)"
+$testDir = (get-item $psscriptroot).parent.FullName
+
+Describe "Test CompatPowerShellGet: Test-PSScriptFileInfo" -tags 'CI' {
+ BeforeAll {
+ $tmpDir1Path = Join-Path -Path $TestDrive -ChildPath "tmpDir1"
+ $tmpDirPaths = @($tmpDir1Path)
+ Get-NewTestDirs($tmpDirPaths)
+
+ # Path to folder, within our test folder, where we store invalid module and script files used for testing
+ $script:testFilesFolderPath = Join-Path $testDir -ChildPath "testFiles"
+
+ # Path to specifically to that invalid test scripts folder
+ $script:testScriptsFolderPath = Join-Path $testFilesFolderPath -ChildPath "testScripts"
+ }
+
+ It "determine script file with minimal required fields as valid" {
+ $scriptFilePath = Join-Path -Path $tmpDir1Path -ChildPath "testscript.ps1"
+ $scriptDescription = "this is a test script"
+ $guid = [guid]::NewGuid()
+ $author = "Script Author"
+ $version = "1.0.0"
+ New-PSScriptFileInfo -Path $scriptFilePath -Description $scriptDescription -Guid $guid -Author $author -Version $version
+ Test-ScriptFileInfo $scriptFilePath | Should -Be $true
+ }
+
+ It "not determine script file with Author field missing as valid" {
+ $scriptName = "InvalidScriptMissingAuthor.ps1"
+ $scriptFilePath = Join-Path $script:testScriptsFolderPath -ChildPath $scriptName
+
+ Test-ScriptFileInfo $scriptFilePath | Should -Be $false
+ }
+
+ It "not determine script file with Description field missing as valid" {
+ $scriptName = "InvalidScriptMissingDescription.ps1"
+ $scriptFilePath = Join-Path $script:testScriptsFolderPath -ChildPath $scriptName
+
+ Test-ScriptFileInfo $scriptFilePath | Should -Be $false
+ }
+
+ It "not determine script that is missing Description block altogether as valid" {
+ $scriptName = "InvalidScriptMissingDescriptionCommentBlock.ps1"
+ $scriptFilePath = Join-Path $script:testScriptsFolderPath -ChildPath $scriptName
+
+ Test-ScriptFileInfo $scriptFilePath | Should -Be $false
+ }
+
+ It "not determine script file Guid as valid" {
+ $scriptName = "InvalidScriptMissingGuid.ps1"
+ $scriptFilePath = Join-Path $script:testScriptsFolderPath -ChildPath $scriptName
+
+ Test-ScriptFileInfo $scriptFilePath | Should -Be $false
+ }
+
+ It "not determine script file missing Version as valid" {
+ $scriptName = "InvalidScriptMissingVersion.ps1"
+ $scriptFilePath = Join-Path $script:testScriptsFolderPath -ChildPath $scriptName
+
+ Test-ScriptFileInfo $scriptFilePath | Should -Be $false
+ }
+
+ It "determine script without empty lines in PSScriptInfo comment content is valid" {
+ $scriptName = "ScriptWithoutEmptyLinesInMetadata.ps1"
+ $scriptFilePath = Join-Path $script:testScriptsFolderPath -ChildPath $scriptName
+
+ Test-ScriptFileInfo $scriptFilePath | Should -Be $true
+ }
+
+ It "determine script without empty lines between comment blocks is valid" {
+ $scriptName = "ScriptWithoutEmptyLinesBetweenCommentBlocks.ps1"
+ $scriptFilePath = Join-Path $script:testScriptsFolderPath -ChildPath $scriptName
+
+ Test-ScriptFileInfo $scriptFilePath | Should -Be $true
+ }
+}
+
+# Ensure that PSGet v2 was not loaded during the test via command discovery
+$PSGetVersionsLoaded = (Get-Module powershellget).Version
+Write-Host "PowerShellGet versions currently loaded: $PSGetVersionsLoaded"
+if ($PSGetVersionsLoaded.Count -gt 1) {
+ throw "There was more than one version of PowerShellGet imported into the current session. `
+ Imported versions include: $PSGetVersionsLoaded"
+}
\ No newline at end of file
diff --git a/Test/UninstallPSResource.Tests.ps1 b/Test/UninstallPSResource.Tests.ps1
new file mode 100644
index 0000000..d911010
--- /dev/null
+++ b/Test/UninstallPSResource.Tests.ps1
@@ -0,0 +1,298 @@
+# Copyright (c) Microsoft Corporation.
+# Licensed under the MIT License.
+
+$ProgressPreference = "SilentlyContinue"
+$modPath = "$psscriptroot/../PSGetTestUtils.psm1"
+Import-Module $modPath -Force -Verbose
+Write-Verbose -Verbose -Message "PowerShellGet version currently loaded: $($(Get-Module powershellget).Version)"
+
+Describe 'Test CompatPowerShellGet: Uninstall-PSResource' -tags 'CI' {
+ BeforeAll{
+ $PSGalleryName = Get-PSGalleryName
+ $testModuleName = "testmodule99"
+ $testModuleName2 = "test_module"
+ $testScriptName = "test_script"
+ Get-NewPSResourceRepositoryFile
+ Set-PSResourceRepository PSGallery -Trusted
+ Uninstall-PSResource -Name $testModuleName -Version "*" -ErrorAction SilentlyContinue
+ Uninstall-PSResource -Name $testScriptName -Version "*" -ErrorAction SilentlyContinue
+ }
+
+ BeforeEach {
+ Install-PSResource $testModuleName -Repository $PSGalleryName -WarningAction SilentlyContinue
+ Install-PSResource $testModuleName2 -Repository $PSGalleryName -SkipDependencyCheck -WarningAction SilentlyContinue
+ Install-PSResource $testScriptName -Repository $PSGalleryName -WarningAction SilentlyContinue
+ }
+
+ AfterEach {
+ Uninstall-PSResource -Name $testModuleName -Version "*" -ErrorAction SilentlyContinue
+ Uninstall-PSResource -Name $testScriptName -Version "*" -ErrorAction SilentlyContinue
+ }
+
+ AfterAll {
+ Get-RevertPSResourceRepositoryFile
+ }
+
+ It "Uninstall-Module" {
+ Uninstall-Module -Name $testModuleName
+
+ $res = Get-InstalledPSResource $testModuleName
+ $res.Count | Should -Be 0
+ }
+
+ It "Uninstall-Script" {
+ Uninstall-Script -Name $testScriptName
+
+ $res = Get-InstalledPSResource $testScriptName
+ $res.Count | Should -Be 0
+ }
+
+ It "Uninstall-Module with -AllVersions" {
+ Install-PSResource $testModuleName -Repository $PSGalleryName -Version "0.0.1"
+ Uninstall-Module -Name $testModuleName -AllVersions
+
+ $res = Get-InstalledPSResource $testModuleName
+ $res.Count | Should -Be 0
+ }
+
+ It "Uninstall-Module with -MinimumVersion" {
+ $minVersion = "0.0.2"
+ Install-PSResource $testModuleName -Repository $PSGalleryName -Version "0.0.1"
+ Uninstall-Module -Name $testModuleName -MinimumVersion $minVersion
+
+ $res = Get-InstalledPSResource $testModuleName
+ $res.Version | Should -BeLessThan $minVersion
+ }
+
+ It "Uninstall-Module with -MaximumVersion" {
+ $maxVersion = "0.0.2"
+ Install-PSResource $testModuleName -Repository $PSGalleryName -Version "0.0.1"
+ Uninstall-Module -Name $testModuleName -MaximumVersion $maxVersion
+
+ $res = Get-InstalledPSResource $testModuleName
+ $res.Version | Should -Not -Contain "0.0.1"
+ }
+
+ It "Uninstall-Script with -AllVersions" {
+ Install-PSResource $testModuleName -Repository $PSGalleryName -Version "0.0.1"
+ Uninstall-Module -Name $testModuleName -AllVersions
+
+ $res = Get-InstalledPSResource $testModuleName
+ $res.Count | Should -Be 0
+ }
+
+ It "Uninstall-Module with -MinimumVersion" {
+ $minVersion = "0.0.2"
+ Install-PSResource $testModuleName -Repository $PSGalleryName -Version "0.0.1"
+ Uninstall-Module -Name $testModuleName -MinimumVersion $minVersion
+
+ $res = Get-InstalledPSResource $testModuleName
+ $res.Version | Should -BeLessThan $minVersion
+ }
+
+ It "Uninstall-Module with -MaximumVersion" {
+ $maxVersion = "0.0.2"
+ Install-PSResource $testModuleName -Repository $PSGalleryName -Version "0.0.1"
+ Uninstall-Module -Name $testModuleName -MaximumVersion $maxVersion
+
+ $res = Get-InstalledPSResource $testModuleName
+ $res.Version | Should -Not -Contain "0.0.1"
+ }
+
+ It "Uninstall a module when given name and specifying all versions" {
+ $null = Install-PSResource $testModuleName -Repository $PSGalleryName -Version "0.0.1" -TrustRepository
+ $null = Install-PSResource $testModuleName -Repository $PSGalleryName -Version "0.0.2" -TrustRepository
+ $null = Install-PSResource $testModuleName -Repository $PSGalleryName -Version "0.0.3" -TrustRepository
+
+ Uninstall-Module -Name $testModuleName -AllVersions
+ $pkgs = Get-InstalledPSResource $testModuleName
+ $pkgs.Version | Should -Not -Contain "0.0.1"
+ $pkgs.Version | Should -Not -Contain "0.0.2"
+ $pkgs.Version | Should -Not -Contain "0.0.3"
+ }
+
+ It "Uninstall a module when given name and using the default version (ie all versions, not explicitly specified)" {
+ $null = Install-PSResource $testModuleName2 -Repository $PSGalleryName -Version "1.0.0" -SkipDependencyCheck -WarningAction SilentlyContinue
+ $null = Install-PSResource $testModuleName2 -Repository $PSGalleryName -Version "3.0.0" -SkipDependencyCheck -WarningAction SilentlyContinue
+ $null = Install-PSResource $testModuleName2 -Repository $PSGalleryName -Version "5.0.0" -SkipDependencyCheck -WarningAction SilentlyContinue
+
+ Uninstall-Module -Name $testModuleName2
+ $pkgs = Get-InstalledPSResource $testModuleName2
+ $pkgs.Version | Should -Not -Contain "1.0.0"
+ $pkgs.Version | Should -Not -Contain "3.0.0"
+ $pkgs.Version | Should -Not -Contain "5.0.0"
+ }
+
+ It "Uninstall module when given Name and specifying exact version" {
+ $null = Install-PSResource $testModuleName2 -Repository $PSGalleryName -Version "1.0.0" -SkipDependencyCheck -WarningAction SilentlyContinue
+ $null = Install-PSResource $testModuleName2 -Repository $PSGalleryName -Version "3.0.0" -SkipDependencyCheck -WarningAction SilentlyContinue
+ $null = Install-PSResource $testModuleName2 -Repository $PSGalleryName -Version "5.0.0" -SkipDependencyCheck -WarningAction SilentlyContinue
+
+ Uninstall-Module -Name $testModuleName2 -RequiredVersion "3.0.0"
+ $pkgs = Get-InstalledPSResource -Name $testModuleName2
+ $pkgs.Version | Should -Not -Contain "1.0.0"
+ }
+
+ $testCases = @{Version="[1.0.0.0]"; ExpectedVersion="1.0.0.0"; Reason="validate version, exact match"},
+ @{Version="1.0.0.0"; ExpectedVersion="1.0.0.0"; Reason="validate version, exact match without bracket syntax"}
+ It "Uninstall module when given Name to " -TestCases $testCases {
+ param($Version, $ExpectedVersion)
+ Uninstall-Module -Name $testModuleName2 -AllVersions
+ $null = Install-PSResource $testModuleName2 -Repository $PSGalleryName -Version "1.0.0" -SkipDependencyCheck -WarningAction SilentlyContinue
+ $null = Install-PSResource $testModuleName2 -Repository $PSGalleryName -Version "3.0.0" -SkipDependencyCheck -WarningAction SilentlyContinue
+ $null = Install-PSResource $testModuleName2 -Repository $PSGalleryName -Version "5.0.0" -SkipDependencyCheck -WarningAction SilentlyContinue
+
+ Uninstall-Module -Name $testModuleName2 -RequiredVersion $Version
+ $pkgs = Get-InstalledPSResource $testModuleName2
+ $pkgs.Version | Should -Not -Contain $Version
+ }
+
+ $testCases2 = @{Version='[5.*.0]'; Description="version with wilcard in middle"},
+ @{Version='[*.0.0.0]'; Description="version with wilcard at start"},
+ @{Version='[5.*.0.0]'; Description="version with wildcard at second digit"},
+ @{Version='[5.0.*.0]'; Description="version with wildcard at third digit"}
+ @{Version='[5.0.0.*]'; Description="version with wildcard at end"},
+ @{Version='[5..0.0]'; Description="version with missing digit in middle"},
+ @{Version='[5.0.0.]'; Description="version with missing digit at end"},
+ @{Version='[5.0.0.0.0]'; Description="version with more than 4 digits"}
+
+ It "Do not uninstall module with incorrectly formatted version such as " -TestCases $testCases2 {
+ param($Version, $Description)
+
+ {Uninstall-Module -Name $testModuleName2 -RequiredVersion $Version} | Should -Throw "Argument for -Version parameter is not in the proper format."
+ }
+
+ $testCases3 = @{Version='(5.0.0.0)'; Description="exclusive version (1.0.0.0)"},
+ @{Version='[5-0-0-0]'; Description="version formatted with invalid delimiter"}
+
+ It "Do not uninstall module with incorrectly formatted version such as " -TestCases $testCases3 {
+ param($Version, $Description)
+
+ try {
+ Uninstall-Module -Name $testModuleName2 -Version $Version -ErrorAction SilentlyContinue
+ }
+ catch
+ {}
+ $pkg = Get-InstalledPSResource $testModuleName2 -Version "5.0.0.0"
+ $pkg.Version | Should -Be "5.0.0.0"
+ }
+
+ It "Uninstall prerelease version module when prerelease version specified" {
+ $version = "1.0.0-beta2"
+ Install-PSResource -Name $testModuleName -Version $version -Repository $PSGalleryName
+ Uninstall-Module -Name $testModuleName -RequiredVersion $version
+ $res = Get-InstalledPSResource $testModuleName -Version "1.0.0"
+ $res | Should -BeNullOrEmpty
+ }
+
+ It "Not uninstall non-prerelease version module when similar prerelease version is specified" {
+ # testmodule99 has a version 0.0.1, but no version 0.0.1-preview.
+ # despite the core version part being the same this uninstall on a nonexistant prerelease version should not be successful
+ Install-PSResource -Name $testModuleName -Version "0.0.1" -Repository $PSGalleryName
+ Uninstall-Module -Name $testModuleName -RequiredVersion "0.0.1-preview" -ErrorAction SilentlyContinue
+ $res = Get-InstalledPSResource -Name $testModuleName -Version "0.0.1"
+ $res.Name | Should -Be $testModuleName
+ $res.Version | Should -Be "0.0.1"
+ }
+
+ It "Uninstall prerelease version script when prerelease version specified" {
+ Install-PSResource -Name $testScriptName -Version "3.0.0-alpha" -Repository $PSGalleryName -TrustRepository
+ Uninstall-Script -Name $testScriptName -RequiredVersion "3.0.0-alpha"
+ $res = Get-InstalledPSResource -Name $testScriptName
+ $res | Should -BeNullOrEmpty
+ }
+
+ It "Not uninstall non-prerelease version module when prerelease version specified" {
+ Install-PSResource -Name $testScriptName -Version "2.5.0.0" -Repository $PSGalleryName -TrustRepository
+ Uninstall-Script -Name $testScriptName -RequiredVersion "2.5.0-alpha001" -ErrorAction SilentlyContinue
+ $res = Get-InstalledPSResource -Name $testScriptName -Version "2.5.0.0"
+ $res.Name | Should -Be $testScriptName
+ $res.Version | Should -Be "2.5"
+ }
+
+ $testCases = @{Name="Test?Module"; ErrorId="ErrorFilteringNamesForUnsupportedWildcards"},
+ @{Name="Test[Module"; ErrorId="ErrorFilteringNamesForUnsupportedWildcards"}
+
+ It "not uninstall module given Name with invalid wildcard characters" -TestCases $testCases {
+ param($Name, $ErrorId)
+ Uninstall-Module -Name $Name -ErrorVariable err -ErrorAction SilentlyContinue
+ $err.Count | Should -Not -Be 0
+ $err[0].FullyQualifiedErrorId | Should -BeExactly "$ErrorId,Microsoft.PowerShell.PowerShellGet.Cmdlets.UninstallPSResource"
+ }
+
+ It "Uninstall a list of modules by name" {
+ $null = Install-PSResource "testmodule99" -Repository $PSGalleryName -TrustRepository -WarningAction SilentlyContinue -SkipDependencyCheck
+
+ Uninstall-Module -Name $testModuleName, "testmodule99"
+ Get-InstalledPSResource $testModuleName, "testmodule99" | Should -BeNullOrEmpty
+ }
+
+ It "Uninstall a specific script by name" {
+ $null = Install-PSResource $testScriptName -Repository $PSGalleryName -TrustRepository
+ $res = Get-InstalledPSResource -Name $testScriptName
+ $res.Name | Should -Be $testScriptName
+
+ Uninstall-Script -Name $testScriptName
+ $res = Get-InstalledPSResource -Name $testScriptName
+ $res | Should -BeNullOrEmpty
+ }
+
+ It "Uninstall a list of scripts by name" {
+ $null = Install-PSResource $testScriptName, "Required-Script1" -Repository $PSGalleryName -TrustRepository
+ $res = Get-InstalledPSResource -Name $testScriptName
+ $res.Name | Should -Be $testScriptName
+ $res2 = Get-InstalledPSResource -Name "Required-Script1"
+ $res2.Name | Should -Be "Required-Script1"
+
+ Uninstall-Script -Name $testScriptName, "Required-Script1"
+ $res = Get-InstalledPSResource -Name $testScriptName
+ $res | Should -BeNullOrEmpty
+ $res2 = Get-InstalledPSResource -Name "Required-Script1"
+ $res2 | Should -BeNullOrEmpty
+ }
+
+ It "Uninstall module using -WhatIf, should not uninstall the module" {
+ Uninstall-Module -Name $testModuleName -WhatIf
+ $pkg = Get-InstalledPSResource $testModuleName
+ $pkg.Version | Should -Be "0.0.93"
+ }
+
+ It "Do not Uninstall module that is a dependency for another module" {
+ $null = Install-PSResource "test_module" -Repository $PSGalleryName -TrustRepository -WarningAction SilentlyContinue
+
+ Uninstall-Module -Name "RequiredModule1" -ErrorVariable ev -ErrorAction SilentlyContinue
+
+ $pkg = Get-InstalledPSResource "RequiredModule1"
+ $pkg | Should -Not -Be $null
+
+ $ev.FullyQualifiedErrorId | Should -BeExactly 'UninstallPSResourcePackageIsaDependency,Microsoft.PowerShell.PowerShellGet.Cmdlets.UninstallPSResource', 'UninstallResourceError,Microsoft.PowerShell.PowerShellGet.Cmdlets.UninstallPSResource'
+ }
+
+ It "Uninstall PSResourceInfo object piped in" {
+ $version = "0.0.93"
+ Install-PSResource -Name $testModuleName -Version $version -Repository $PSGalleryName -TrustRepository
+ Get-InstalledPSResource -Name $testModuleName -Version $version | Uninstall-Module
+ $res = Get-InstalledPSResource -Name $testModuleName -Version $version
+ $res | Should -BeNullOrEmpty
+ }
+
+ It "Uninstall PSResourceInfo object piped in for prerelease version object" {
+ Install-PSResource -Name $testModuleName -Version "1.0.0-beta2" -Repository $PSGalleryName -TrustRepository
+ Get-InstalledPSResource -Name $testModuleName -Version "1.0.0-beta2" | Uninstall-Module
+ $res = Get-InstalledPSResource -Name $testModuleName -Version "1.0.0-beta2"
+ $res | Should -BeNullOrEmpty
+ }
+
+ It "Uninstall module that is not installed should throw error" {
+ Uninstall-Module -Name "NonInstalledModule" -ErrorVariable ev -ErrorAction SilentlyContinue
+ $ev.FullyQualifiedErrorId | Should -BeExactly 'UninstallResourceError,Microsoft.PowerShell.PowerShellGet.Cmdlets.UninstallPSResource'
+ }
+}
+
+# Ensure that PSGet v2 was not loaded during the test via command discovery
+$PSGetVersionsLoaded = (Get-Module powershellget).Version
+Write-Host "PowerShellGet versions currently loaded: $PSGetVersionsLoaded"
+if ($PSGetVersionsLoaded.Count -gt 1) {
+ throw "There was more than one version of PowerShellGet imported into the current session. `
+ Imported versions include: $PSGetVersionsLoaded"
+}
\ No newline at end of file
diff --git a/Test/UnregisterPSResourceRepository.Tests.ps1 b/Test/UnregisterPSResourceRepository.Tests.ps1
new file mode 100644
index 0000000..ca2a5b2
--- /dev/null
+++ b/Test/UnregisterPSResourceRepository.Tests.ps1
@@ -0,0 +1,91 @@
+# Copyright (c) Microsoft Corporation.
+# Licensed under the MIT License.
+
+$modPath = "$psscriptroot/../PSGetTestUtils.psm1"
+Import-Module $modPath -Force -Verbose
+Write-Verbose -Verbose -Message "PowerShellGet version currently loaded: $($(Get-Module powershellget).Version)"
+
+Describe "Test CompatPowerShellGet: Unregister-PSResourceRepository" -tags 'CI' {
+ BeforeEach {
+ $PSGalleryName = Get-PSGalleryName
+ $PSGalleryUri = Get-PSGalleryLocation
+ Get-NewPSResourceRepositoryFile
+ $tmpDir1Path = Join-Path -Path $TestDrive -ChildPath "tmpDir1"
+ $tmpDir2Path = Join-Path -Path $TestDrive -ChildPath "tmpDir2"
+ $tmpDir3Path = Join-Path -Path $TestDrive -ChildPath "tmpDir3"
+ $tmpDirPaths = @($tmpDir1Path, $tmpDir2Path, $tmpDir3Path)
+ Get-NewTestDirs($tmpDirPaths)
+ }
+ AfterEach {
+ Get-RevertPSResourceRepositoryFile
+ $tmpDir1Path = Join-Path -Path $TestDrive -ChildPath "tmpDir1"
+ $tmpDir2Path = Join-Path -Path $TestDrive -ChildPath "tmpDir2"
+ $tmpDir3Path = Join-Path -Path $TestDrive -ChildPath "tmpDir3"
+ $tmpDirPaths = @($tmpDir1Path, $tmpDir2Path, $tmpDir3Path)
+ Get-RemoveTestDirs($tmpDirPaths)
+ }
+
+ It "unregister single repository previously registered" {
+ Register-PSResourceRepository -Name "testRepository" -Uri $tmpDir1Path
+ Unregister-PSRepository -Name "testRepository"
+
+ $res = Get-PSResourceRepository -Name "testRepository" -ErrorVariable err -ErrorAction SilentlyContinue
+ $res | Should -BeNullOrEmpty
+ }
+
+ It "unregister multiple repositories previously registered" {
+ Register-PSResourceRepository -Name "testRepository" -Uri $tmpDir1Path
+ Register-PSResourceRepository -Name "testRepository2" -Uri $tmpDir2Path
+ Unregister-PSRepository -Name "testRepository","testRepository2"
+
+ $res = Get-PSResourceRepository -Name "testRepository","testRepository2" -ErrorVariable err -ErrorAction SilentlyContinue
+ $res | Should -BeNullOrEmpty
+ }
+
+ It "not unregister repo not previously registered and throw expected error message" {
+ $name = "nonRegisteredRepository"
+ {Unregister-PSRepository -Name $name -ErrorAction Stop} | Should -Throw -ErrorId "ErrorUnregisteringSpecifiedRepo,Microsoft.PowerShell.PowerShellGet.Cmdlets.UnregisterPSResourceRepository"
+
+ }
+
+ It "not register when -Name contains wildcard" {
+ Register-PSResourceRepository -Name "testRepository" -Uri $tmpDir1Path
+ Register-PSResourceRepository -Name "testRepository2" -Uri $tmpDir2Path
+ Unregister-PSRepository -Name "testRepository*" -ErrorVariable err -ErrorAction SilentlyContinue
+ $err.Count | Should -BeGreaterThan 0
+ $err[0].FullyQualifiedErrorId | Should -BeExactly "nameContainsWildCardError,Microsoft.PowerShell.PowerShellGet.Cmdlets.UnregisterPSResourceRepository"
+ }
+
+ It "when multiple repo Names provided, if one name isn't valid unregister the rest and write error message" {
+ $nonRegisteredRepoName = "nonRegisteredRepository"
+ Register-PSResourceRepository -Name "testRepository" -Uri $tmpDir1Path
+ Unregister-PSRepository -Name $nonRegisteredRepoName,"testRepository" -ErrorVariable err -ErrorAction SilentlyContinue
+ $err.Count | Should -BeGreaterThan 0
+ $err[0].FullyQualifiedErrorId | Should -BeExactly "ErrorUnregisteringSpecifiedRepo,Microsoft.PowerShell.PowerShellGet.Cmdlets.UnregisterPSResourceRepository"
+ }
+
+ It "throw error if Name is null or empty" {
+ {Unregister-PSRepository -Name "" -ErrorAction Stop} | Should -Throw -ErrorId "ParameterArgumentValidationError,Unregister-PSRepository"
+ }
+
+ It "throw error if Name is null" {
+ {Unregister-PSRepository -Name $null -ErrorAction Stop} | Should -Throw -ErrorId "ParameterArgumentValidationError,Unregister-PSRepository"
+ }
+
+ It "unregister repository PSGallery" {
+ Unregister-PSRepository -Name $PSGalleryName
+
+ $res = Get-PSResourceRepository -Name $PSGalleryName -ErrorVariable err -ErrorAction SilentlyContinue
+ $res | Should -BeNullOrEmpty
+ $err.Count | Should -BeGreaterThan 0
+ $err[0].FullyQualifiedErrorId | Should -BeExactly "ErrorGettingSpecifiedRepo,Microsoft.PowerShell.PowerShellGet.Cmdlets.GetPSResourceRepository"
+ }
+}
+
+# Ensure that PSGet v2 was not loaded during the test via command discovery
+$PSGetVersionsLoaded = (Get-Module powershellget).Version
+Write-Host "PowerShellGet versions currently loaded: $PSGetVersionsLoaded"
+if ($PSGetVersionsLoaded.Count -gt 1) {
+ throw "There was more than one version of PowerShellGet imported into the current session. `
+ Imported versions include: $PSGetVersionsLoaded"
+}
\ No newline at end of file
diff --git a/Test/UpdatePSModuleManifest.Tests.ps1 b/Test/UpdatePSModuleManifest.Tests.ps1
new file mode 100644
index 0000000..8baaeca
--- /dev/null
+++ b/Test/UpdatePSModuleManifest.Tests.ps1
@@ -0,0 +1,415 @@
+# Copyright (c) Microsoft Corporation.
+# Licensed under the MIT License.
+
+$ProgressPreference = "SilentlyContinue"
+$modPath = "$psscriptroot/../PSGetTestUtils.psm1"
+Import-Module $modPath -Force -Verbose
+Write-Verbose -Verbose -Message "PowerShellGet version currently loaded: $($(Get-Module powershellget).Version)"
+
+Describe 'Test CompatPowerShellGet: Update-ModuleManifest' {
+
+ BeforeEach {
+ # Create temp module manifest to be updated
+ $script:TempModulesPath = Join-Path $TestDrive "PSGet_$(Get-Random)"
+ $null = New-Item -Path $script:TempModulesPath -ItemType Directory -Force
+
+ $script:UpdateModuleManifestName = "PSGetTestModule"
+ $script:UpdateModuleManifestBase = Join-Path $script:TempModulesPath $script:UpdateModuleManifestName
+ $null = New-Item -Path $script:UpdateModuleManifestBase -ItemType Directory -Force
+
+ $script:testManifestPath = Microsoft.PowerShell.Management\Join-Path -Path $script:UpdateModuleManifestBase -ChildPath "$script:UpdateModuleManifestName.psd1"
+ }
+
+ AfterEach {
+ RemoveItem "$script:TempModulesPath"
+ }
+
+ It "Update module manifest given Path parameter" {
+ $description = "This is a PowerShellGet test"
+ New-ModuleManifest -Path $script:testManifestPath
+ Update-ModuleManifest -Path $script:testManifestPath -Description $description
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.Description | Should -Be $description
+ }
+
+ It "Update module manifest given Guid parameter" {
+ $Guid = [guid]::NewGuid()
+ New-ModuleManifest -Path $script:testManifestPath
+ Update-ModuleManifest -Path $script:testManifestPath -Guid $Guid
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.Guid | Should -Be $Guid
+ }
+
+ It "Update module manifest given Author parameter" {
+ $Author = "Test Author"
+ New-ModuleManifest -Path $script:testManifestPath
+ Update-ModuleManifest -Path $script:testManifestPath -Author $Author
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.Author | Should -Be $Author
+ }
+
+ It "Update module manifest given Description parameter" {
+ $Description = "PowerShellGet test description"
+ New-ModuleManifest -Path $script:testManifestPath
+ Update-ModuleManifest -Path $script:testManifestPath -Description $Description
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.Description | Should -Be $Description
+ }
+
+ It "Update module manifest given ModuleVersion parameter" {
+ $ModuleVersion = "7.0.0.0"
+ New-ModuleManifest -Path $script:testManifestPath
+ Update-ModuleManifest -Path $script:testManifestPath -ModuleVersion $ModuleVersion
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.Version.ToString() | Should -Be $ModuleVersion
+ }
+
+ It "Update module manifest given RequiredModules parameter" {
+ $requiredModuleName = 'PackageManagement'
+ $requiredModuleVersion = '1.0.0.0'
+ $RequiredModules = @(@{ModuleName = $requiredModuleName; ModuleVersion = $requiredModuleVersion })
+ New-ModuleManifest -Path $script:testManifestPath
+ Update-ModuleManifest -Path $script:testManifestPath -RequiredModules $RequiredModules -Description "test"
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ foreach ($module in $results.RequiredModules)
+ {
+ $module | Should -Be $requiredModuleName
+ $module.Version | Should -Be $requiredModuleVersion
+ }
+ }
+
+ It "Update module manifest given Prerelease parameter" {
+ $Description = "Test Description"
+ $ModuleVersion = "1.0.0"
+ $Prerelease = "preview"
+ New-ModuleManifest -Path $script:testManifestPath -Description $Description -ModuleVersion $ModuleVersion
+ Update-ModuleManifest -Path $script:testManifestPath -Prerelease $Prerelease
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.PrivateData.PSData.Prerelease | Should -Be $Prerelease
+ }
+
+ It "Update module manifest given ReleaseNotes parameter" {
+ $Description = "Test Description"
+ $ReleaseNotes = "Release notes for module."
+ New-ModuleManifest -Path $script:testManifestPath -Description $Description
+ Update-ModuleManifest -Path $script:testManifestPath -ReleaseNotes $ReleaseNotes
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.PrivateData.PSData.ReleaseNotes | Should -Be $ReleaseNotes
+ }
+
+ It "Update module manifest given Tags parameter" {
+ $Description = "Test Description"
+ $Tag1 = "tag1"
+ $Tag2 = "tag2"
+ New-ModuleManifest -Path $script:testManifestPath -Description $Description
+ Update-ModuleManifest -Path $script:testManifestPath -Tags $Tag1, $Tag2
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.PrivateData.PSData.Tags | Should -Be @($Tag1, $Tag2)
+ }
+
+ It "Update module manifest given ProjectUri parameter" {
+ $Description = "Test Description"
+ $ProjectUri = "https://www.testprojecturi.com/"
+ New-ModuleManifest -Path $script:testManifestPath -Description $Description
+ Update-ModuleManifest -Path $script:testManifestPath -ProjectUri $ProjectUri
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.PrivateData.PSData.ProjectUri | Should -Be $ProjectUri
+ }
+
+ It "Update module manifest given LicenseUri parameter" {
+ $Description = "Test Description"
+ $LicenseUri = "https://www.testlicenseuri.com/"
+ New-ModuleManifest -Path $script:testManifestPath -Description $Description
+ Update-ModuleManifest -Path $script:testManifestPath -LicenseUri $LicenseUri
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.PrivateData.PSData.LicenseUri | Should -Be $LicenseUri
+ }
+
+ It "Update module manifest given IconUri parameter" {
+ $Description = "Test Description"
+ $IconUri = "https://www.testiconuri.com/"
+ New-ModuleManifest -Path $script:testManifestPath -Description $Description
+ Update-ModuleManifest -Path $script:testManifestPath -IconUri $IconUri
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.PrivateData.PSData.IconUri | Should -Be $IconUri
+ }
+
+ It "Update module manifest given RequireLicenseAcceptance parameter" {
+ $Description = "PowerShellGet test description"
+ New-ModuleManifest -Path $script:testManifestPath -Description $Description
+ Update-ModuleManifest -Path $script:testManifestPath -RequireLicenseAcceptance
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.PrivateData.PSData.RequireLicenseAcceptance | Should -Be $true
+ }
+
+ It "Update module manifest given ExternalModuleDependencies parameter" {
+ $Description = "Test Description"
+ $ExternalModuleDep1 = "ExternalModuleDep1"
+ $ExternalModuleDep2 = "ExternalModuleDep2"
+ $ExternalModuleDep1FileName = "ExternalModuleDep1.psm1"
+ $ExternalModuleDep2FileName = "ExternalModuleDep2.psm1"
+ $ExternalModuleDepPath1 = Microsoft.PowerShell.Management\Join-Path -Path $script:UpdateModuleManifestBase -ChildPath $ExternalModuleDep1FileName
+ $ExternalModuleDepPath2 = Microsoft.PowerShell.Management\Join-Path -Path $script:UpdateModuleManifestBase -ChildPath $ExternalModuleDep2FileName
+
+ $null = New-Item -Path $ExternalModuleDepPath1 -ItemType File -Force
+ $null = New-Item -Path $ExternalModuleDepPath2 -ItemType File -Force
+
+ New-ModuleManifest -Path $script:testManifestPath -Description $Description -NestedModules $ExternalModuleDep1, $ExternalModuleDep2
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.PrivateData.PSData.ExternalModuleDependencies | Should -Be $null
+
+ Update-ModuleManifest -Path $script:testManifestPath -ExternalModuleDependencies $ExternalModuleDep1, $ExternalModuleDep2
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.PrivateData.PSData.ExternalModuleDependencies | Should -Be @($ExternalModuleDep1, $ExternalModuleDep2)
+ }
+
+ It "Update module manifest given PowerShellHostName parameter" {
+ $Description = "PowerShellGet test description"
+ $PowerShellHostName = $Host.Name
+ New-ModuleManifest -Path $script:testManifestPath -Description $Description
+ Update-ModuleManifest -Path $script:testManifestPath -PowerShellHostName $PowerShellHostName
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath -ErrorAction SilentlyContinue
+ $results.PowerShellHostName | Should -Be $PowerShellHostName
+ }
+
+ It "Update module manifest given DefaultCommandPrefix parameter" {
+ $Description = "PowerShellGet test description"
+ $DefaultCommandPrefix = "testprefix"
+ New-ModuleManifest -Path $script:testManifestPath -Description $Description
+ Update-ModuleManifest -Path $script:testManifestPath -DefaultCommandPrefix $DefaultCommandPrefix
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.Prefix | Should -Be $DefaultCommandPrefix
+ }
+
+ It "Update module manifest given RootModule parameter" {
+ $Description = "Test Description"
+ $RootModuleName = $script:UpdateModuleManifestName + ".psm1"
+ $RootModulePath = Microsoft.PowerShell.Management\Join-Path -Path $script:UpdateModuleManifestBase -ChildPath $RootModuleName
+ $null = New-Item -Path $RootModulePath -ItemType File -Force
+
+ New-ModuleManifest -Path $script:testManifestPath -Description $Description
+ Update-ModuleManifest -Path $script:testManifestPath -RootModule $RootModuleName
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.RootModule | Should -Be $RootModuleName
+ }
+
+ It "Update module manifest given RequiredAssemblies parameter" {
+ $Description = "Test Description"
+ $RequiredAssembly1 = "RequiredAssembly1.dll"
+ $RequiredAssembly2 = "RequiredAssembly2.dll"
+ $RequiredAssemblyPath1 = Microsoft.PowerShell.Management\Join-Path -Path $script:UpdateModuleManifestBase -ChildPath $RequiredAssembly1
+ $RequiredAssemblyPath2 = Microsoft.PowerShell.Management\Join-Path -Path $script:UpdateModuleManifestBase -ChildPath $RequiredAssembly2
+
+ $null = New-Item -Path $RequiredAssemblyPath1 -ItemType File -Force
+ $null = New-Item -Path $RequiredAssemblyPath2 -ItemType File -Force
+
+ New-ModuleManifest -Path $script:testManifestPath -Description $Description
+ Update-ModuleManifest -Path $script:testManifestPath -RequiredAssemblies $RequiredAssembly1, $RequiredAssembly2
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.RequiredAssemblies | Should -Be @($RequiredAssembly1, $RequiredAssembly2)
+ }
+
+ It "Update module manifest given NestedModules parameter" {
+ $Description = "Test Description"
+ $NestedModule1 = "NestedModule1"
+ $NestedModule2 = "NestedModule2"
+ $NestModuleFileName1 = "NestedModule1.dll"
+ $NestModuleFileName2 = "NestedModule2.dll"
+ $NestedModulePath1 = Microsoft.PowerShell.Management\Join-Path -Path $script:UpdateModuleManifestBase -ChildPath $NestModuleFileName1
+ $NestedModulePath2 = Microsoft.PowerShell.Management\Join-Path -Path $script:UpdateModuleManifestBase -ChildPath $NestModuleFileName2
+
+ $null = New-Item -Path $NestedModulePath1 -ItemType File -Force
+ $null = New-Item -Path $NestedModulePath2 -ItemType File -Force
+
+ New-ModuleManifest -Path $script:testManifestPath -Description $Description
+ Update-ModuleManifest -Path $script:testManifestPath -NestedModules $NestedModule1, $NestedModule2
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.NestedModules | Should -Be @($NestedModule1, $NestedModule2)
+ }
+
+ It "Update module manifest given FileList parameter" {
+ $Description = "Test Description"
+ $FileList1 = "FileList1.cs"
+ $FileList2 = "FileList2.cs"
+ $FileListPath1 = Microsoft.PowerShell.Management\Join-Path -Path $script:UpdateModuleManifestBase -ChildPath $FileList1
+ $FileListPath2 = Microsoft.PowerShell.Management\Join-Path -Path $script:UpdateModuleManifestBase -ChildPath $FileList2
+
+ $null = New-Item -Path $FileListPath1 -ItemType File -Force
+ $null = New-Item -Path $FileListPath2 -ItemType File -Force
+
+ New-ModuleManifest -Path $script:testManifestPath -Description $Description
+ Update-ModuleManifest -Path $script:testManifestPath -FileList $FileList1, $FileList2
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.FileList | Should -Be @($FileListPath1, $FileListPath2)
+ }
+
+ It "Update module manifest given TypesToProcess parameter" {
+ $Description = "Test Description"
+ $TypeFile = "TypeFile.ps1xml"
+ $TypeFilePath = Microsoft.PowerShell.Management\Join-Path -Path $script:UpdateModuleManifestBase -ChildPath $TypeFile
+
+ $null = New-Item -Path $TypeFilePath -ItemType File -Force
+
+ New-ModuleManifest -Path $script:testManifestPath -Description $Description
+ Update-ModuleManifest -Path $script:testManifestPath -TypesToProcess $TypeFile
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.ExportedTypeFiles | Should -Be $TypeFilePath
+ }
+
+ It "Update module manifest given FormatsToProcess parameter" {
+ $Description = "Test Description"
+ $FormatFile = "FormatFile.ps1xml"
+ $FormatFilePath = Microsoft.PowerShell.Management\Join-Path -Path $script:UpdateModuleManifestBase -ChildPath $FormatFile
+
+ $null = New-Item -Path $FormatFilePath -ItemType File -Force
+
+ New-ModuleManifest -Path $script:testManifestPath -Description $Description
+ Update-ModuleManifest -Path $script:testManifestPath -FormatsToProcess $FormatFile
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.ExportedFormatFiles | Should -Be $FormatFilePath
+ }
+
+ It "Update module manifest given ScriptsToProcess parameter" {
+ $Description = "Test Description"
+ $Script1 = "Script1.ps1"
+ $Script2 = "Script2.ps1"
+ $ScriptPath1 = Microsoft.PowerShell.Management\Join-Path -Path $script:UpdateModuleManifestBase -ChildPath $Script1
+ $ScriptPath2 = Microsoft.PowerShell.Management\Join-Path -Path $script:UpdateModuleManifestBase -ChildPath $Script2
+
+ $null = New-Item -Path $ScriptPath1 -ItemType File -Force
+ $null = New-Item -Path $ScriptPath2 -ItemType File -Force
+
+ New-ModuleManifest -Path $script:testManifestPath -Description $Description
+ Update-ModuleManifest -Path $script:testManifestPath -ScriptsToProcess $Script1, $Script2
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.Scripts | Should -Be @($ScriptPath1, $ScriptPath2)
+ }
+
+ It "Update module manifest given ProcessorArchitecture parameter" {
+ $Description = "Test Description"
+ $ProcessorArchitecture = [System.Reflection.ProcessorArchitecture]::Amd64
+ New-ModuleManifest -Path $script:testManifestPath -Description $Description
+ Update-ModuleManifest -Path $script:testManifestPath -ProcessorArchitecture $ProcessorArchitecture
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.ProcessorArchitecture | Should -Be $ProcessorArchitecture
+ }
+
+ It "Update module manifest given ModuleList parameter" {
+ $Description = "Test Description"
+ $ModuleList1 = "PowerShellGet"
+ New-ModuleManifest -Path $script:testManifestPath -Description $Description
+ Update-ModuleManifest -Path $script:testManifestPath -ModuleList $ModuleList1
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.ModuleList | Should -Be $ModuleList1
+ }
+
+ It "Update module manifest given CompanyName, Copyright, PowerShellHostVersion, ClrVersion, DotnetFrameworkVersion, PowerShellVersion, HelpInfoUri, and CompatiblePSEditions" {
+ $Description = "Test Description"
+ $CompanyName = "Test CompanyName"
+ $Copyright = "Test Copyright"
+ $PowerShellHostVersion = "5.0"
+ $ClrVersion = "1.0"
+ $DotnetFrameworkVersion = "2.0"
+ $PowerShellVersion = "5.1"
+ $HelpInfoUri = "https://www.testhelpinfouri.com/"
+ $CompatiblePSEditions = @("Desktop", "Core")
+
+ New-ModuleManifest -Path $script:testManifestPath -Description $Description
+ Update-ModuleManifest -Path $script:testManifestPath `
+ -CompanyName $CompanyName `
+ -Copyright $Copyright `
+ -PowerShellVersion $PowerShellVersion `
+ -ClrVersion $ClrVersion `
+ -DotNetFrameworkVersion $DotnetFrameworkVersion `
+ -PowerShellHostVersion $PowerShellHostVersion `
+ -HelpInfoUri $HelpInfoUri `
+ -CompatiblePSEditions $CompatiblePSEditions
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.CompanyName | Should -Be $CompanyName
+ $results.Copyright | Should -Be $Copyright
+ $results.PowerShellVersion | Should -Be $PowerShellVersion
+ $results.ClrVersion | Should -Be $ClrVersion
+ $results.DotnetFrameworkVersion | Should -Be $DotnetFrameworkVersion
+ $results.PowerShellHostVersion | Should -Be $PowerShellHostVersion
+ $results.HelpInfoUri | Should -Be $HelpInfoUri
+ $results.CompatiblePSEditions | Should -Be $CompatiblePSEditions
+ }
+
+ It "Update module manifest given FunctionsToExport, AliasesToExport, and VariablesToExport parameters" -Skip:(Get-IsWindows) {
+ $Description = "Test Description"
+ $ExportedFunctions = "FunctionToExport1", "FunctionToExport2"
+ $ExportedAliases = "AliasToExport1", "AliasToExport2"
+ $ExportedVariables = "VariablesToExport1", "Variables2Export2"
+ New-ModuleManifest -Path $script:testManifestPath -Description $Description
+ Update-ModuleManifest -Path $script:testManifestPath `
+ -FunctionsToExport $ExportedFunctions `
+ -AliasesToExport $ExportedAliases `
+ -VariablesToExport $ExportedVariables
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.ExportedFunctions.Keys | Should -Be $ExportedFunctions
+ $results.ExportedAliases.Keys | Should -Be $ExportedAliases
+ $results.ExportedVariables.Keys | Should -Be $ExportedVariables
+ }
+
+ It "Update module manifest given CmdletsToExport parameters" {
+ $Description = "Test Description"
+ $CmdletToExport1 = "CmdletToExport1"
+ $CmdletToExport2 = "CmdletToExport2"
+
+ New-ModuleManifest -Path $script:testManifestPath -Description $Description
+ Update-ModuleManifest -Path $script:testManifestPath -CmdletsToExport $CmdletToExport1, $CmdletToExport2
+
+ $results = Get-Content -Path $script:testManifestPath -Raw
+ $results.Contains($CmdletToExport1) | Should -Be $true
+ $results.Contains($CmdletToExport2) | Should -Be $true
+ }
+
+ It "Update module manifest should not overwrite over old data unless explcitly specified" {
+ $Description = "Test Description"
+ $ModuleVersion = "2.0.0"
+ $Author = "Leto Atriedes"
+ $ProjectUri = "https://www.arrakis.gov/"
+ $Prerelease = "Preview"
+ New-ModuleManifest -Path $script:testManifestPath -Description $Description -ModuleVersion $ModuleVersion -Author $Author -ProjectUri $ProjectUri
+ Update-ModuleManifest -Path $script:testManifestPath -Prerelease $Prerelease
+
+ $results = Test-ModuleManifest -Path $script:testManifestPath
+ $results.Author | Should -Be $Author
+ $results.PrivateData.PSData.ProjectUri | Should -Be $ProjectUri
+ $results.PrivateData.PSData.Prerelease | Should -Be $Prerelease
+ }
+}
+
+# Ensure that PSGet v2 was not loaded during the test via command discovery
+$PSGetVersionsLoaded = (Get-Module powershellget).Version
+Write-Host "PowerShellGet versions currently loaded: $PSGetVersionsLoaded"
+if ($PSGetVersionsLoaded.Count -gt 1) {
+ throw "There was more than one version of PowerShellGet imported into the current session. `
+ Imported versions include: $PSGetVersionsLoaded"
+}
\ No newline at end of file
diff --git a/Test/UpdatePSResource.Tests.ps1 b/Test/UpdatePSResource.Tests.ps1
new file mode 100644
index 0000000..9e839f8
--- /dev/null
+++ b/Test/UpdatePSResource.Tests.ps1
@@ -0,0 +1,376 @@
+# Copyright (c) Microsoft Corporation.
+# Licensed under the MIT License.
+
+$ProgressPreference = "SilentlyContinue"
+$modPath = "$psscriptroot/../PSGetTestUtils.psm1"
+Import-Module $modPath -Force -Verbose
+Write-Verbose -Verbose -Message "PowerShellGet version currently loaded: $($(Get-Module powershellget).Version)"
+
+Describe 'Test CompatPowerShellGet: Update-PSResource' -tags 'CI' {
+
+ BeforeAll {
+ $PSGalleryName = Get-PSGalleryName
+ $NuGetGalleryName = Get-NuGetGalleryName
+ $testModuleName = "test_module"
+ $testModuleName2 = "TestModule99"
+ Get-NewPSResourceRepositoryFile
+ Get-PSResourceRepository
+ Set-PSResourceRepository -Name PSGallery -Trusted
+ }
+
+ AfterEach {
+ Uninstall-PSResource "test_module", "TestModule99", "TestModuleWithLicense", "TestModuleWithDependencyB", "TestModuleWithDependencyD" -Version "*" -ErrorAction SilentlyContinue
+ }
+
+ AfterAll {
+ Get-RevertPSResourceRepositoryFile
+ }
+
+ It "Update-Module" {
+ Install-Module $testModuleName2 -RequiredVersion 0.0.91 -Repository PSGallery
+ Update-Module $testModuleName2
+
+ $res = Get-InstalledPSResource $testModuleName2
+ $res.Version | Should -Contain "0.0.93"
+ }
+
+ It "Update-Module with -RequiredVersion" {
+ Install-Module $testModuleName2 -RequiredVersion 0.0.91 -Repository PSGallery
+ Update-Module $testModuleName2 -RequiredVersion 0.0.93 -WarningVariable wv
+ $wv | Should -HaveCount 1
+
+ $res = Get-InstalledPSResource $testModuleName2
+ $res.version | Should -Contain "0.0.93"
+ }
+
+ It "Update-Module multiple modules" {
+ Install-Module "TestModuleWithDependencyB" -Repository PSGallery -RequiredVersion "2.0"
+ Install-Module "TestModuleWithDependencyD" -Repository PSGallery -RequiredVersion "1.0"
+
+ Update-Module "TestModuleWithDependencyB", "TestModuleWithDependencyD"
+ $res = Get-InstalledPSResource "TestModuleWithDependencyB", "TestModuleWithDependencyD"
+ $res | Should -HaveCount 4
+ $res.version | Should -Contain "2.0"
+ $res.version | Should -Contain "3.0"
+ }
+
+ It "Update-Module with RequiredVersion and wildcard" {
+ Install-Module $testModuleName2 -RequiredVersion 0.0.91 -Repository PSGallery
+ Update-Module "testModule9*"
+ $res = Get-InstalledPSResource $testModuleName2
+ $res | Should -HaveCount 2
+ $res.version | Should -Contain "0.0.93"
+ }
+
+ It "Update-Module with -PassThru should return output" {
+ Install-Module $testModuleName2 -RequiredVersion 0.0.91 -Repository PSGallery
+ $res = Update-Module $testModuleName2 -PassThru
+ $res | Should -Not -BeNullOrEmpty
+ }
+
+ It "Update-Module with lower -RequiredVersion should not update" {
+ Install-Module $testModuleName2 -Repository PSGallery
+ Update-Module $testModuleName2 -RequiredVersion 0.0.3 -ErrorAction SilentlyContinue
+ $res = Get-InstalledPSResource $testModuleName2
+ $res.Count | Should -Be 1
+ $res.version | Should -Be "0.0.93"
+ }
+
+ It "UpdateAllModules" {
+ Install-Module $testModuleName2 -Repository PSGallery -RequiredVersion 0.0.7
+ Install-Module "TestModuleWithDependencyB" -Repository PSGallery -RequiredVersion 2.0
+ Install-Module "TestModuleWithDependencyD" -Repository PSGallery -RequiredVersion 1.0
+
+ Update-Module $testModuleName2, "TestModuleWithDependencyB", "TestModuleWithDependencyD"
+ $res = Get-InstalledPSResource $testModuleName2, "TestModuleWithDependencyB", "TestModuleWithDependencyD"
+ $res | Should -HaveCount 6
+ $res.version | Should -Contain "0.0.93"
+ $res.version | Should -Contain "3.0"
+ $res.version | Should -Contain "2.0"
+ }
+
+ It "Update-Module with not available -RequiredVersion" {
+ Install-Module $testModuleName2 -RequiredVersion "0.0.2" -Repository PSGallery
+
+ Update-Module $testModuleName2 -RequiredVersion 10.0 -ErrorAction SilentlyContinue -ErrorVariable ev
+
+ $res = Get-InstalledPSResource $testModuleName2
+ $res | Should -HaveCount 1
+ $res.Version | Should -Be ([System.Version]"0.0.2")
+ }
+
+ It "Update-Module with Dependencies" {
+ $parentModule = "TestModuleWithDependencyC"
+ $childModule1 = "TestModuleWithDependencyB"
+ $childModule2 = "TestModuleWithDependencyD"
+ $childModule3 = "TestModuleWithDependencyF"
+ Install-Module $parentModule -Repository PSGallery -RequiredVersion "3.0"
+ Update-Module $parentModule
+
+ $res = Get-InstalledPSResource $parentModule, $childModule1, $childModule2, $childModule3
+ $res | Should -HaveCount 8
+ $res.Version | Should -Contain "5.0"
+ }
+
+ It "Update resource installed given Name and Version (specific) parameters" {
+ Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository
+
+ Update-Module -Name $testModuleName -RequiredVersion "5.0.0.0"
+ $res = Get-InstalledPSResource -Name $testModuleName
+ $isPkgUpdated = $false
+ foreach ($pkg in $res)
+ {
+ if ([System.Version]$pkg.Version -eq [System.Version]"5.0.0.0")
+ {
+ $isPkgUpdated = $true
+ }
+ }
+
+ $isPkgUpdated | Should -BeTrue
+ }
+
+ $testCases2 = @{Version="[3.0.0.0]"; ExpectedVersions=@("1.0.0.0", "3.0.0.0"); Reason="validate version, exact match"},
+ @{Version="3.0.0.0"; ExpectedVersions=@("1.0.0.0", "3.0.0.0"); Reason="validate version, exact match without bracket syntax"},
+ @{Version="[3.0.0.0, 5.0.0.0]"; ExpectedVersions=@("1.0.0.0", "3.0.0.0", "5.0.0.0"); Reason="validate version, exact range inclusive"},
+ @{Version="(3.0.0.0, 6.0.0.0)"; ExpectedVersions=@("1.0.0.0", "3.0.0.0", "5.0.0.0"); Reason="validate version, exact range exclusive"},
+ @{Version="(3.0.0.0,)"; ExpectedVersions=@("1.0.0.0", "5.0.0.0"); Reason="validate version, minimum version exclusive"},
+ @{Version="[3.0.0.0,)"; ExpectedVersions=@("1.0.0.0", "3.0.0.0", "5.0.0.0"); Reason="validate version, minimum version inclusive"},
+ @{Version="(,5.0.0.0)"; ExpectedVersions=@("1.0.0.0", "3.0.0.0"); Reason="validate version, maximum version exclusive"},
+ @{Version="(,5.0.0.0]"; ExpectedVersions=@("1.0.0.0", "3.0.0.0", "5.0.0.0"); Reason="validate version, maximum version inclusive"},
+ @{Version="[1.0.0.0, 5.0.0.0)"; ExpectedVersions=@("1.0.0.0", "3.0.0.0"); Reason="validate version, mixed inclusive minimum and exclusive maximum version"}
+ @{Version="(1.0.0.0, 3.0.0.0]"; ExpectedVersions=@("1.0.0.0", "3.0.0.0"); Reason="validate version, mixed exclusive minimum and inclusive maximum version"}
+
+ It "Update resource when given Name to " -TestCases $testCases2{
+ param($Version, $ExpectedVersions)
+
+ Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository
+ Update-Module -Name $testModuleName -RequiredVersion $Version
+
+ $res = Get-InstalledPSResource -Name $testModuleName
+
+ foreach ($item in $res) {
+ $item.Name | Should -Be $testModuleName
+ $ExpectedVersions | Should -Contain $item.Version
+ }
+ }
+
+ $testCases = @(
+ @{Version='(3.0.0.0)'; Description="exclusive version (3.0.0.0)"},
+ @{Version='[3-0-0-0]'; Description="version formatted with invalid delimiter [3-0-0-0]"}
+ )
+ It "Should not update resource with incorrectly formatted version such as " -TestCases $testCases{
+ param($Version, $Description)
+
+ Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository
+ Update-Module -Name $testModuleName -RequiredVersion $Version 2>$null
+
+ $res = Get-InstalledPSResource -Name $testModuleName
+ $isPkgUpdated = $false
+ foreach ($pkg in $res)
+ {
+ if ([System.Version]$pkg.Version -gt [System.Version]"1.0.0.0")
+ {
+ $isPkgUpdated = $true
+ }
+ }
+
+ $isPkgUpdated | Should -Be $false
+ }
+
+ It "Update resource with latest (including prerelease) version given Prerelease parameter" {
+ Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository
+ Update-Module -Name $testModuleName -AllowPrerelease
+ $res = Get-InstalledPSResource -Name $testModuleName
+
+ $isPkgUpdated = $false
+ foreach ($pkg in $res)
+ {
+ if ([System.Version]$pkg.Version -ge [System.Version]"5.2.5")
+ {
+ $pkg.Prerelease | Should -Be "alpha001"
+ $isPkgUpdated = $true
+ }
+ }
+
+ $isPkgUpdated | Should -Be $true
+ }
+
+ # Windows only
+ It "update resource under CurrentUser scope" -skip:(!($IsWindows -and (Test-IsAdmin))) {
+ # TODO: perhaps also install TestModule with the highest version (the one above 1.2.0.0) to the AllUsers path too
+ Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository -Scope AllUsers
+ Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository -Scope CurrentUser
+
+ Update-Module -Name $testModuleName -RequiredVersion "3.0.0.0" -Scope CurrentUser
+
+ $res = Get-InstalledPSResource -Name $testModuleName
+
+ $isPkgUpdated = $false
+ foreach ($pkg in $res)
+ {
+ if ([System.Version]$pkg.Version -gt [System.Version]"1.0.0.0")
+ {
+ $pkg.InstalledLocation.Contains("Documents") | Should -Be $true
+ $isPkgUpdated = $true
+ }
+ }
+
+ $isPkgUpdated | Should -Be $true
+ }
+
+ # Windows only
+ It "update resource under AllUsers scope" -skip:(!($IsWindows -and (Test-IsAdmin))) {
+ Install-PSResource -Name "testmodule99" -Version "0.0.91" -Repository $PSGalleryName -TrustRepository -Scope AllUsers
+ Install-PSResource -Name "testmodule99" -Version "0.0.91" -Repository $PSGalleryName -TrustRepository -Scope CurrentUser
+
+ Update-Module -Name "testmodule99" -RequiredVersion "0.0.93" -Scope AllUsers
+
+ $res = Get-Module -Name "testmodule99" -ListAvailable
+ $res | Should -Not -BeNullOrEmpty
+ $res.Version | Should -Contain "0.0.93"
+ }
+
+ # Windows only
+ It "Update resource under no specified scope" -skip:(!$IsWindows) {
+ Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository
+ Update-Module -Name $testModuleName -RequiredVersion "3.0.0.0"
+
+ $res = Get-InstalledPSResource -Name $testModuleName
+
+ $isPkgUpdated = $false
+ foreach ($pkg in $res)
+ {
+ if ([System.Version]$pkg.Version -gt [System.Version]"1.0.0.0")
+ {
+ $pkg.InstalledLocation.Contains("Documents") | Should -Be $true
+ $isPkgUpdated = $true
+ }
+ }
+
+ $isPkgUpdated | Should -Be $true
+ }
+
+ # Unix only
+ # Expected path should be similar to: '/home/janelane/.local/share/powershell/Modules'
+ It "Update resource under CurrentUser scope - Unix only" -Skip:(Get-IsWindows) {
+ # this line is commented out because AllUsers scope requires sudo and that isn't supported in CI yet
+ # Install-PSResource -Name "TestModule" -Version "1.1.0.0" -Repository $TestGalleryName -Scope AllUsers
+ Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository -Scope CurrentUser
+
+ Update-Module -Name $testModuleName -Scope CurrentUser
+
+ $res = Get-InstalledPSResource -Name $testModuleName
+
+ $isPkgUpdated = $false
+ foreach ($pkg in $res)
+ {
+ if ([System.Version]$pkg.Version -gt [System.Version]"1.0.0.0")
+ {
+ $pkg.InstalledLocation.Contains("$env:HOME/.local") | Should -Be $true
+ $isPkgUpdated = $true
+ }
+ }
+
+ $isPkgUpdated | Should -Be $true
+ }
+
+ # Unix only
+ # Expected path should be similar to: '/usr/local/share/powershell/Modules'
+ # this test is skipped because it requires sudo to run and has yet to be resolved in CI
+ It "Update resource under AllUsers scope - Unix only" -Skip:($true) {
+ Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository -Scope AllUsers
+ Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository -Scope CurrentUser
+
+ Update-Module -Name $testModuleName -Scope AllUsers
+
+ $res = Get-InstalledPSResource -Name $testModuleName
+
+ $isPkgUpdated = $false
+ foreach ($pkg in $res)
+ {
+ if ([System.Version]$pkg.Version -gt [System.Version]"1.0.0.0")
+ {
+ $pkg.InstalledLocation.Contains("usr") | Should -Be $true
+ $isPkgUpdated = $true
+ }
+ }
+
+ $isPkgUpdated | Should -Be $true
+ }
+
+ # Unix only
+ # Expected path should be similar to: '/home/janelane/.local/share/powershell/Modules'
+ It "Update resource under no specified scope - Unix only" -Skip:(Get-IsWindows) {
+ # this is commented out because it requires sudo to run with AllUsers scope and this hasn't been resolved in CI yet
+ # Install-PSResource -Name "TestModule" -Version "1.1.0.0" -Repository $TestGalleryName -Scope AllUsers
+ Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository -Scope CurrentUser
+
+ Update-Module -Name $testModuleName
+
+ $res = Get-InstalledPSResource -Name $testModuleName
+
+ $isPkgUpdated = $false
+ foreach ($pkg in $res)
+ {
+ if ([System.Version]$pkg.Version -gt [System.Version]"1.0.0.0")
+ {
+ $pkg.InstalledLocation.Contains("$env:HOME/.local") | Should -Be $true
+ $isPkgUpdated = $true
+ }
+ }
+
+ $isPkgUpdated | Should -Be $true
+ }
+
+ It "Update module using -WhatIf, should not update the module" {
+ Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository
+ Update-Module -Name $testModuleName -WhatIf
+
+ $res = Get-InstalledPSResource -Name $testModuleName
+
+ $isPkgUpdated = $false
+ foreach ($pkg in $res)
+ {
+ if ([System.Version]$pkg.Version -gt [System.Version]"1.0.0.0")
+ {
+ $isPkgUpdated = $true
+ }
+ }
+
+ $isPkgUpdated | Should -Be $false
+ }
+
+ It "Update resource installed given -Name and -PassThru parameters" {
+ Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository
+
+ $res = Update-Module -Name $testModuleName -RequiredVersion "3.0.0.0" -PassThru
+ $res.Name | Should -Contain $testModuleName
+ $res.Version | Should -Contain "3.0.0.0"
+ }
+
+ It "Update resource installed given -Name and -Force parameters" {
+ Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository
+
+ Update-Module -Name $testModuleName -RequiredVersion "3.0.0.0" -Foce
+ $res = Get-InstalledPSResource -Name $testModuleName
+
+ $isPkgUpdated = $false
+ foreach ($pkg in $res)
+ {
+ if ([System.Version]$pkg.Version -gt [System.Version]"1.0.0.0")
+ {
+ $isPkgUpdated = $true
+ }
+ }
+
+ $isPkgUpdated | Should -Be $true
+ }
+}
+
+# Ensure that PSGet v2 was not loaded during the test via command discovery
+$PSGetVersionsLoaded = (Get-Module powershellget).Version
+Write-Host "PowerShellGet versions currently loaded: $PSGetVersionsLoaded"
+if ($PSGetVersionsLoaded.Count -gt 1) {
+ throw "There was more than one version of PowerShellGet imported into the current session. `
+ Imported versions include: $PSGetVersionsLoaded"
+}
\ No newline at end of file
diff --git a/Test/UpdatePSScriptFileInfo.Tests.ps1 b/Test/UpdatePSScriptFileInfo.Tests.ps1
new file mode 100644
index 0000000..11bce59
--- /dev/null
+++ b/Test/UpdatePSScriptFileInfo.Tests.ps1
@@ -0,0 +1,314 @@
+# Copyright (c) Microsoft Corporation.
+# Licensed under the MIT License.
+
+$modPath = "$psscriptroot/../PSGetTestUtils.psm1"
+Import-Module $modPath -Force -Verbose
+Write-Verbose -Verbose -Message "PowerShellGet version currently loaded: $($(Get-Module powershellget).Version)"
+$testDir = (get-item $psscriptroot).parent.FullName
+
+Describe "Test CompatPowerShellGet: Update-PSScriptFileInfo" -tags 'CI' {
+ BeforeAll {
+ $tmpDir1Path = Join-Path -Path $TestDrive -ChildPath "tmpDir1"
+ $tmpDirPaths = @($tmpDir1Path)
+ Get-NewTestDirs($tmpDirPaths)
+
+ # Path to folder, within our test folder, where we store invalid module and script files used for testing
+ $script:testFilesFolderPath = Join-Path $testDir -ChildPath "testFiles"
+
+ # Path to specifically to that invalid test scripts folder
+ $script:testScriptsFolderPath = Join-Path $testFilesFolderPath -ChildPath "testScripts"
+
+ $script:newline = [System.Environment]::NewLine;
+ }
+
+ BeforeEach {
+ $script:psScriptInfoName = "test_script"
+ $scriptDescription = "this is a test script"
+ $script:testScriptFilePath = Join-Path -Path $tmpDir1Path -ChildPath "$script:psScriptInfoName.ps1"
+ New-PSScriptFileInfo -Path $script:testScriptFilePath -Description $scriptDescription
+ }
+
+ AfterEach {
+ if (Test-Path -Path $script:testScriptFilePath)
+ {
+ Remove-Item $script:testScriptFilePath
+ }
+ }
+
+ It "Update .ps1 file with relative path" {
+ $relativeCurrentPath = Get-Location
+ $scriptFilePath = Join-Path -Path $relativeCurrentPath -ChildPath "$script:psScriptInfoName.ps1"
+ $oldDescription = "Old description for test script"
+ $newDescription = "New description for test script"
+ New-PSScriptFileInfo -Path $scriptFilePath -Description $oldDescription
+
+ Update-ScriptFileInfo -Path $scriptFilePath -Description $newDescription
+ Test-PSScriptFileInfo -Path $scriptFilePath | Should -BeTrue
+
+ Test-Path -Path $scriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $scriptFilePath -Raw
+ $results.Contains($newDescription) | Should -BeTrue
+ $results -like "*.DESCRIPTION$script:newline*$newDescription*" | Should -BeTrue
+
+ Remove-Item -Path $scriptFilePath -Force
+ }
+
+ It "Update script should not overwrite old script data unless that property is specified" {
+ $description = "Test Description"
+ $version = "3.0.0"
+ $author = "John Doe"
+ $newAuthor = "Jane Doe"
+ $projectUri = "https://testscript.com/"
+
+ $relativeCurrentPath = Get-Location
+ $scriptFilePath = Join-Path -Path $relativeCurrentPath -ChildPath "$script:psScriptInfoName.ps1"
+
+ New-PSScriptFileInfo -Path $scriptFilePath -Description $description -Version $version -Author $author -ProjectUri $projectUri
+ Update-ScriptFileInfo -Path $scriptFilePath -Author $newAuthor
+
+ Test-PSScriptFileInfo -Path $scriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $scriptFilePath -Raw
+ $results.Contains($newAuthor) | Should -BeTrue
+ $results.Contains(".AUTHOR $newAuthor") | Should -BeTrue
+
+ # rest should be original data used when creating the script
+ $results.Contains($projectUri) | Should -BeTrue
+ $results.Contains(".PROJECTURI $projectUri") | Should -BeTrue
+
+ $results.Contains($version) | Should -BeTrue
+ $results.Contains(".VERSION $version") | Should -BeTrue
+
+ $results.Contains($description) | Should -BeTrue
+ $results -like "*.DESCRIPTION$script:newline*$description*" | Should -BeTrue
+
+ Remove-Item -Path $scriptFilePath -Force
+ }
+
+ It "update script file Author property" {
+ $author = "New Author"
+ Update-ScriptFileInfo -Path $script:testScriptFilePath -Author $author
+ Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($author) | Should -BeTrue
+ $results.Contains(".AUTHOR $author") | Should -BeTrue
+ }
+
+ It "update script file Version property" {
+ $version = "2.0.0.0"
+ Update-ScriptFileInfo -Path $script:testScriptFilePath -Version $version
+ Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($version) | Should -BeTrue
+ $results.Contains(".VERSION $version") | Should -BeTrue
+ }
+
+ It "update script file Version property with prerelease version" {
+ $version = "3.0.0-alpha"
+ Update-ScriptFileInfo -Path $script:testScriptFilePath -Version $version
+ Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($version) | Should -BeTrue
+ $results.Contains(".VERSION $version") | Should -BeTrue
+ }
+
+ It "not update script file with invalid version" {
+ Update-ScriptFileInfo -Path $script:testScriptFilePath -Version "4.0.0.0.0" -ErrorVariable err -ErrorAction SilentlyContinue
+ $err.Count | Should -Not -Be 0
+ $err[0].FullyQualifiedErrorId | Should -BeExactly "VersionParseIntoNuGetVersion,Microsoft.PowerShell.PowerShellGet.Cmdlets.UpdatePSScriptFileInfo"
+ }
+
+ It "update script file Description property" {
+ $description = "this is an updated test script"
+ Update-ScriptFileInfo -Path $script:testScriptFilePath -Description $description
+ Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($description) | Should -BeTrue
+ $results -like "*.DESCRIPTION$script:newline*$description*" | Should -BeTrue
+ }
+
+ It "update script file Guid property" {
+ $guid = [Guid]::NewGuid();
+ Update-ScriptFileInfo -Path $script:testScriptFilePath -Guid $guid
+ Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($guid) | Should -BeTrue
+ $results.Contains(".GUID $guid") | Should -BeTrue
+ }
+
+ It "update script file CompanyName property" {
+ $companyName = "New Corporation"
+ Update-ScriptFileInfo -Path $script:testScriptFilePath -CompanyName $companyName
+ Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($companyName) | Should -BeTrue
+ $results.Contains(".COMPANYNAME $companyName") | Should -BeTrue
+ }
+
+ It "update script file Copyright property" {
+ $copyright = "(c) 2022 New Corporation. All rights reserved"
+ Update-ScriptFileInfo -Path $script:testScriptFilePath -Copyright $copyright
+ Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($copyright) | Should -BeTrue
+ $results.Contains(".COPYRIGHT $copyright") | Should -BeTrue
+ }
+
+ It "update script file ExternalModuleDependencies property" {
+ $externalModuleDep1 = "ExternalModuleDep1"
+ $externalModuleDep2 = "ExternalModuleDep2"
+ Update-ScriptFileInfo -Path $script:testScriptFilePath -ExternalModuleDependencies $externalModuleDep1,$externalModuleDep2
+ Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($externalModuleDep1) | Should -BeTrue
+ $results.Contains($externalModuleDep2) | Should -BeTrue
+ $results -like "*.EXTERNALMODULEDEPENDENCIES*$externalModuleDep1*$externalModuleDep2*" | Should -BeTrue
+ }
+
+ It "update script file ExternalScriptDependencies property" {
+ $externalScriptDep1 = "ExternalScriptDep1"
+ $externalScriptDep2 = "ExternalScriptDep2"
+ Update-ScriptFileInfo -Path $script:testScriptFilePath -ExternalScriptDependencies $externalScriptDep1,$externalScriptDep2
+ Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($externalScriptDep1) | Should -BeTrue
+ $results.Contains($externalScriptDep2) | Should -BeTrue
+ $results -like "*.EXTERNALMODULEDEPENDENCIES*$externalScriptDep1*$externalScriptDep2*" | Should -BeTrue
+ }
+
+ It "update script file IconUri property" {
+ $iconUri = "https://testscript.com/icon"
+ Update-ScriptFileInfo -Path $script:testScriptFilePath -IconUri $iconUri
+ Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($iconUri) | Should -BeTrue
+ $results.Contains(".ICONURI $iconUri") | Should -BeTrue
+ }
+
+ It "update script file LicenseUri property" {
+ $licenseUri = "https://testscript.com/license"
+ Update-ScriptFileInfo -Path $script:testScriptFilePath -LicenseUri $licenseUri
+ Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($licenseUri) | Should -BeTrue
+ $results.Contains(".LICENSEURI $licenseUri") | Should -BeTrue
+ }
+
+ It "update script file ProjectUri property" {
+ $projectUri = "https://testscript.com/"
+ Update-ScriptFileInfo -Path $script:testScriptFilePath -ProjectUri $projectUri
+ Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($projectUri) | Should -BeTrue
+ $results.Contains(".PROJECTURI $projectUri") | Should -BeTrue
+ }
+
+ It "update script file PrivateData property" {
+ $privateData = "this is some private data"
+ Update-ScriptFileInfo -Path $script:testScriptFilePath -PrivateData $privateData
+ Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($privateData) | Should -BeTrue
+ $results -like "*.PRIVATEDATA*$privateData*" | Should -BeTrue
+ }
+
+ It "update script file ReleaseNotes property" {
+ $releaseNotes = "Release notes for script."
+ Update-ScriptFileInfo -Path $script:testScriptFilePath -ReleaseNotes $releaseNotes
+ Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($releaseNotes) | Should -BeTrue
+ $results -like "*.RELEASENOTES$script:newline*$releaseNotes*" | Should -BeTrue
+ }
+
+ It "update script file RequiredModules property" {
+ $hashtable1 = @{ModuleName = "RequiredModule1"}
+ $hashtable2 = @{ModuleName = "RequiredModule2"; ModuleVersion = "1.0.0.0"}
+ $hashtable3 = @{ModuleName = "RequiredModule3"; RequiredVersion = "2.5.0.0"}
+ $hashtable4 = @{ModuleName = "RequiredModule4"; ModuleVersion = "1.1.0.0"; MaximumVersion = "2.0.0.0"}
+ $requiredModules = @($hashtable1, $hashtable2, $hashtable3, $hashtable4)
+
+ Update-ScriptFileInfo -Path $script:testScriptFilePath -RequiredModules $requiredModules
+ Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+
+ $results.Contains("#Requires -Module RequiredModule1") | Should -BeTrue
+ $results -like "*#Requires*ModuleName*Version*" | Should -BeTrue
+ }
+
+ It "update script file RequiredScripts property" {
+ $requiredScript1 = "RequiredScript1"
+ $requiredScript2 = "RequiredScript2"
+ Update-ScriptFileInfo -Path $script:testScriptFilePath -RequiredScripts $requiredScript1, $requiredScript2
+ Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($requiredScript1) | Should -BeTrue
+ $results.Contains($requiredScript2) | Should -BeTrue
+ $results -like "*.REQUIREDSCRIPTS*$requiredScript1*$requiredScript2*" | Should -BeTrue
+ }
+
+ It "update script file Tags property" {
+ $tag1 = "tag1"
+ $tag2 = "tag2"
+ Update-ScriptFileInfo -Path $script:testScriptFilePath -Tags $tag1, $tag2
+ Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true
+
+ Test-Path -Path $script:testScriptFilePath | Should -BeTrue
+ $results = Get-Content -Path $script:testScriptFilePath -Raw
+ $results.Contains($tag1) | Should -BeTrue
+ $results.Contains($tag2) | Should -BeTrue
+ $results.Contains(".TAGS $tag1 $tag2") | Should -BeTrue
+ }
+
+ It "throw error when attempting to update a signed script without -RemoveSignature parameter" {
+ # Note: user should sign the script again once it's been updated
+
+ $scriptName = "ScriptWithSignature.ps1"
+ $scriptFilePath = Join-Path $script:testScriptsFolderPath -ChildPath $scriptName
+
+ # use a copy of the signed script file so we can re-use for other tests
+ $null = Copy-Item -Path $scriptFilePath -Destination $TestDrive
+ $tmpScriptFilePath = Join-Path -Path $TestDrive -ChildPath $scriptName
+
+ { Update-ScriptFileInfo -Path $tmpScriptFilePath -Version "2.0.0.0" } | Should -Throw -ErrorId "ScriptToBeUpdatedContainsSignature,Microsoft.PowerShell.PowerShellGet.Cmdlets.UpdatePSScriptFileInfo"
+ }
+}
+
+# Ensure that PSGet v2 was not loaded during the test via command discovery
+$PSGetVersionsLoaded = (Get-Module powershellget).Version
+Write-Host "PowerShellGet versions currently loaded: $PSGetVersionsLoaded"
+if ($PSGetVersionsLoaded.Count -gt 1) {
+ throw "There was more than one version of PowerShellGet imported into the current session. `
+ Imported versions include: $PSGetVersionsLoaded"
+}
\ No newline at end of file
diff --git a/Test/testFiles/testModules/incorrectdepmoduleversion/incorrectdepmoduleversion.psd1 b/Test/testFiles/testModules/incorrectdepmoduleversion/incorrectdepmoduleversion.psd1
new file mode 100644
index 0000000..03769fd
--- /dev/null
+++ b/Test/testFiles/testModules/incorrectdepmoduleversion/incorrectdepmoduleversion.psd1
@@ -0,0 +1,132 @@
+#
+# Module manifest for module 'testmodule-incorrect'
+#
+# Generated by: americks
+#
+# Generated on: 5/18/2022
+#
+
+@{
+
+ # Script module or binary module file associated with this manifest.
+ # RootModule = ''
+
+ # Version number of this module.
+ ModuleVersion = '1.0.0.0'
+
+ # Supported PSEditions
+ # CompatiblePSEditions = @()
+
+ # ID used to uniquely identify this module
+ GUID = '4f56ed2b-72af-4c29-bda6-ef3dc91c1624'
+
+ # Author of this module
+ Author = 'americks'
+
+ # Company or vendor of this module
+ CompanyName = 'Unknown'
+
+ # Copyright statement for this module
+ Copyright = '(c) americks. All rights reserved.'
+
+ # Description of the functionality provided by this module
+ Description = 'incorrectdepmoduleversion module'
+
+ # Minimum version of the PowerShell engine required by this module
+ # PowerShellVersion = ''
+
+ # Name of the PowerShell host required by this module
+ # PowerShellHostName = ''
+
+ # Minimum version of the PowerShell host required by this module
+ # PowerShellHostVersion = ''
+
+ # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
+ # DotNetFrameworkVersion = ''
+
+ # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
+ # ClrVersion = ''
+
+ # Processor architecture (None, X86, Amd64) required by this module
+ # ProcessorArchitecture = ''
+
+ # Modules that must be imported into the global environment prior to importing this module
+ RequiredModules = @(@{ModuleName = 'PackageManagement'; ModuleVersion = '1..0.0'; })
+
+ # Assemblies that must be loaded prior to importing this module
+ # RequiredAssemblies = @()
+
+ # Script files (.ps1) that are run in the caller's environment prior to importing this module.
+ # ScriptsToProcess = @()
+
+ # Type files (.ps1xml) to be loaded when importing this module
+ # TypesToProcess = @()
+
+ # Format files (.ps1xml) to be loaded when importing this module
+ # FormatsToProcess = @()
+
+ # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
+ # NestedModules = @()
+
+ # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
+ FunctionsToExport = '*'
+
+ # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
+ CmdletsToExport = '*'
+
+ # Variables to export from this module
+ VariablesToExport = '*'
+
+ # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
+ AliasesToExport = '*'
+
+ # DSC resources to export from this module
+ # DscResourcesToExport = @()
+
+ # List of all modules packaged with this module
+ # ModuleList = @()
+
+ # List of all files packaged with this module
+ # FileList = @()
+
+ # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
+ PrivateData = @{
+
+ PSData = @{
+
+ # Tags applied to this module. These help with module discovery in online galleries.
+ # Tags = @()
+
+ # A URL to the license for this module.
+ # LicenseUri = ''
+
+ # A URL to the main website for this project.
+ # ProjectUri = ''
+
+ # A URL to an icon representing this module.
+ # IconUri = ''
+
+ # ReleaseNotes of this module
+ # ReleaseNotes = ''
+
+ # Prerelease string of this module
+ # Prerelease = ''
+
+ # Flag to indicate whether the module requires explicit user acceptance for install/update/save
+ # RequireLicenseAcceptance = $false
+
+ # External dependent modules of this module
+ # ExternalModuleDependencies = @()
+
+ } # End of PSData hashtable
+
+ } # End of PrivateData hashtable
+
+ # HelpInfo URI of this module
+ # HelpInfoURI = ''
+
+ # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
+ # DefaultCommandPrefix = ''
+
+ }
+
\ No newline at end of file
diff --git a/Test/testFiles/testModules/incorrectmoduleversion/incorrectmoduleversion.psd1 b/Test/testFiles/testModules/incorrectmoduleversion/incorrectmoduleversion.psd1
new file mode 100644
index 0000000..83f6245
--- /dev/null
+++ b/Test/testFiles/testModules/incorrectmoduleversion/incorrectmoduleversion.psd1
@@ -0,0 +1,132 @@
+#
+# Module manifest for module 'testmodule-incorrect'
+#
+# Generated by: americks
+#
+# Generated on: 5/18/2022
+#
+
+@{
+
+# Script module or binary module file associated with this manifest.
+# RootModule = ''
+
+# Version number of this module.
+ModuleVersion = '1..0.0'
+
+# Supported PSEditions
+# CompatiblePSEditions = @()
+
+# ID used to uniquely identify this module
+GUID = '4f56ed2b-72af-4c29-bda6-ef3dc91c1604'
+
+# Author of this module
+Author = 'americks'
+
+# Company or vendor of this module
+CompanyName = 'Unknown'
+
+# Copyright statement for this module
+Copyright = '(c) americks. All rights reserved.'
+
+# Description of the functionality provided by this module
+Description = 'incorrectmoduleversion module'
+
+# Minimum version of the PowerShell engine required by this module
+# PowerShellVersion = ''
+
+# Name of the PowerShell host required by this module
+# PowerShellHostName = ''
+
+# Minimum version of the PowerShell host required by this module
+# PowerShellHostVersion = ''
+
+# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
+# DotNetFrameworkVersion = ''
+
+# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
+# ClrVersion = ''
+
+# Processor architecture (None, X86, Amd64) required by this module
+# ProcessorArchitecture = ''
+
+# Modules that must be imported into the global environment prior to importing this module
+RequiredModules = @(@{ModuleName = 'PackageManagement'; ModuleVersion = '1.0.0.0'; })
+
+# Assemblies that must be loaded prior to importing this module
+# RequiredAssemblies = @()
+
+# Script files (.ps1) that are run in the caller's environment prior to importing this module.
+# ScriptsToProcess = @()
+
+# Type files (.ps1xml) to be loaded when importing this module
+# TypesToProcess = @()
+
+# Format files (.ps1xml) to be loaded when importing this module
+# FormatsToProcess = @()
+
+# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
+# NestedModules = @()
+
+# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
+FunctionsToExport = '*'
+
+# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
+CmdletsToExport = '*'
+
+# Variables to export from this module
+VariablesToExport = '*'
+
+# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
+AliasesToExport = '*'
+
+# DSC resources to export from this module
+# DscResourcesToExport = @()
+
+# List of all modules packaged with this module
+# ModuleList = @()
+
+# List of all files packaged with this module
+# FileList = @()
+
+# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
+PrivateData = @{
+
+ PSData = @{
+
+ # Tags applied to this module. These help with module discovery in online galleries.
+ # Tags = @()
+
+ # A URL to the license for this module.
+ # LicenseUri = ''
+
+ # A URL to the main website for this project.
+ # ProjectUri = ''
+
+ # A URL to an icon representing this module.
+ # IconUri = ''
+
+ # ReleaseNotes of this module
+ # ReleaseNotes = ''
+
+ # Prerelease string of this module
+ # Prerelease = ''
+
+ # Flag to indicate whether the module requires explicit user acceptance for install/update/save
+ # RequireLicenseAcceptance = $false
+
+ # External dependent modules of this module
+ # ExternalModuleDependencies = @()
+
+ } # End of PSData hashtable
+
+} # End of PrivateData hashtable
+
+# HelpInfo URI of this module
+# HelpInfoURI = ''
+
+# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
+# DefaultCommandPrefix = ''
+
+}
+
diff --git a/Test/testFiles/testScripts/InvalidScriptMissingAuthor.ps1 b/Test/testFiles/testScripts/InvalidScriptMissingAuthor.ps1
new file mode 100644
index 0000000..11ecd96
--- /dev/null
+++ b/Test/testFiles/testScripts/InvalidScriptMissingAuthor.ps1
@@ -0,0 +1,43 @@
+
+<#PSScriptInfo
+
+.VERSION 1.0
+
+.GUID 3951be04-bd06-4337-8dc3-a620bf539fbd
+
+.AUTHOR
+
+.COMPANYNAME
+
+.COPYRIGHT
+
+.TAGS
+
+.LICENSEURI
+
+.PROJECTURI
+
+.ICONURI
+
+.EXTERNALMODULEDEPENDENCIES
+
+.REQUIREDSCRIPTS
+
+.EXTERNALSCRIPTDEPENDENCIES
+
+.RELEASENOTES
+
+
+.PRIVATEDATA
+
+#>
+
+<#
+
+.DESCRIPTION
+ this is a test for a script that will be published remotely
+
+#>
+Param()
+
+
diff --git a/Test/testFiles/testScripts/InvalidScriptMissingAuthorAndVersion.ps1 b/Test/testFiles/testScripts/InvalidScriptMissingAuthorAndVersion.ps1
new file mode 100644
index 0000000..fc69050
--- /dev/null
+++ b/Test/testFiles/testScripts/InvalidScriptMissingAuthorAndVersion.ps1
@@ -0,0 +1,43 @@
+
+<#PSScriptInfo
+
+.VERSION
+
+.GUID 3951be04-bd06-4337-8dc3-a620bf539fbd
+
+.AUTHOR
+
+.COMPANYNAME
+
+.COPYRIGHT
+
+.TAGS
+
+.LICENSEURI
+
+.PROJECTURI
+
+.ICONURI
+
+.EXTERNALMODULEDEPENDENCIES
+
+.REQUIREDSCRIPTS
+
+.EXTERNALSCRIPTDEPENDENCIES
+
+.RELEASENOTES
+
+
+.PRIVATEDATA
+
+#>
+
+<#
+
+.DESCRIPTION
+ this is a test for a script that will be published remotely
+
+#>
+Param()
+
+
diff --git a/Test/testFiles/testScripts/InvalidScriptMissingDescription.ps1 b/Test/testFiles/testScripts/InvalidScriptMissingDescription.ps1
new file mode 100644
index 0000000..cdfed58
--- /dev/null
+++ b/Test/testFiles/testScripts/InvalidScriptMissingDescription.ps1
@@ -0,0 +1,42 @@
+
+<#PSScriptInfo
+
+.VERSION 1.0
+
+.GUID 3951be04-bd06-4337-8dc3-a620bf539fbd
+
+.AUTHOR annavied
+
+.COMPANYNAME
+
+.COPYRIGHT
+
+.TAGS
+
+.LICENSEURI
+
+.PROJECTURI
+
+.ICONURI
+
+.EXTERNALMODULEDEPENDENCIES
+
+.REQUIREDSCRIPTS
+
+.EXTERNALSCRIPTDEPENDENCIES
+
+.RELEASENOTES
+
+
+.PRIVATEDATA
+
+#>
+
+<#
+
+.DESCRIPTION
+
+#>
+Param()
+
+
diff --git a/Test/testFiles/testScripts/InvalidScriptMissingDescriptionCommentBlock.ps1 b/Test/testFiles/testScripts/InvalidScriptMissingDescriptionCommentBlock.ps1
new file mode 100644
index 0000000..b3cd98e
--- /dev/null
+++ b/Test/testFiles/testScripts/InvalidScriptMissingDescriptionCommentBlock.ps1
@@ -0,0 +1,37 @@
+
+<#PSScriptInfo
+
+.VERSION 1.0
+
+.GUID 3951be04-bd06-4337-8dc3-a620bf539fbd
+
+.AUTHOR annavied
+
+.COMPANYNAME
+
+.COPYRIGHT
+
+.TAGS
+
+.LICENSEURI
+
+.PROJECTURI
+
+.ICONURI
+
+.EXTERNALMODULEDEPENDENCIES
+
+.REQUIREDSCRIPTS
+
+.EXTERNALSCRIPTDEPENDENCIES
+
+.RELEASENOTES
+
+
+.PRIVATEDATA
+
+#>
+
+Param()
+
+
diff --git a/Test/testFiles/testScripts/InvalidScriptMissingGuid.ps1 b/Test/testFiles/testScripts/InvalidScriptMissingGuid.ps1
new file mode 100644
index 0000000..7cf637e
--- /dev/null
+++ b/Test/testFiles/testScripts/InvalidScriptMissingGuid.ps1
@@ -0,0 +1,43 @@
+
+<#PSScriptInfo
+
+.VERSION 1.0
+
+.GUID
+
+.AUTHOR annavied
+
+.COMPANYNAME
+
+.COPYRIGHT
+
+.TAGS
+
+.LICENSEURI
+
+.PROJECTURI
+
+.ICONURI
+
+.EXTERNALMODULEDEPENDENCIES
+
+.REQUIREDSCRIPTS
+
+.EXTERNALSCRIPTDEPENDENCIES
+
+.RELEASENOTES
+
+
+.PRIVATEDATA
+
+#>
+
+<#
+
+.DESCRIPTION
+ this is a test for a script that will be published remotely
+
+#>
+Param()
+
+
diff --git a/Test/testFiles/testScripts/InvalidScriptMissingVersion.ps1 b/Test/testFiles/testScripts/InvalidScriptMissingVersion.ps1
new file mode 100644
index 0000000..1c05323
--- /dev/null
+++ b/Test/testFiles/testScripts/InvalidScriptMissingVersion.ps1
@@ -0,0 +1,43 @@
+
+<#PSScriptInfo
+
+.VERSION
+
+.GUID 3951be04-bd06-4337-8dc3-a620bf539fbd
+
+.AUTHOR annavied
+
+.COMPANYNAME
+
+.COPYRIGHT
+
+.TAGS
+
+.LICENSEURI
+
+.PROJECTURI
+
+.ICONURI
+
+.EXTERNALMODULEDEPENDENCIES
+
+.REQUIREDSCRIPTS
+
+.EXTERNALSCRIPTDEPENDENCIES
+
+.RELEASENOTES
+
+
+.PRIVATEDATA
+
+#>
+
+<#
+
+.DESCRIPTION
+ this is a test for a script that will be published remotely
+
+#>
+Param()
+
+
diff --git a/Test/testFiles/testScripts/ScriptWithInvalidProjectUri.ps1 b/Test/testFiles/testScripts/ScriptWithInvalidProjectUri.ps1
new file mode 100644
index 0000000..20a292f
--- /dev/null
+++ b/Test/testFiles/testScripts/ScriptWithInvalidProjectUri.ps1
@@ -0,0 +1,39 @@
+<#PSScriptInfo
+
+.VERSION 1.0.0.0
+
+.GUID 465905fb-e242-4ead-a186-ea2ecf37d280
+
+.AUTHOR alyssavu
+
+.COMPANYNAME
+
+.COPYRIGHT
+
+.TAGS
+
+.LICENSEURI
+
+.PROJECTURI www.powershellgallery.com/api/v2
+
+.ICONURI
+
+.EXTERNALMODULEDEPENDENCIES
+
+.REQUIREDSCRIPTS
+
+.EXTERNALSCRIPTDEPENDENCIES
+
+.RELEASENOTES
+
+
+.PRIVATEDATA
+
+
+#>
+<#
+
+.DESCRIPTION
+This is a test file for a script with invalid ProjectUri
+
+#>
diff --git a/Test/testFiles/testScripts/ScriptWithSignature.ps1 b/Test/testFiles/testScripts/ScriptWithSignature.ps1
new file mode 100644
index 0000000..9bd193a
--- /dev/null
+++ b/Test/testFiles/testScripts/ScriptWithSignature.ps1
@@ -0,0 +1,75 @@
+
+<#PSScriptInfo
+
+.VERSION 1.0
+
+.GUID 3951be04-bd06-4337-8dc3-a620bf539fbd
+
+.AUTHOR annavied
+
+.COMPANYNAME
+
+.COPYRIGHT
+
+.TAGS
+
+.LICENSEURI
+
+.PROJECTURI
+
+.ICONURI
+
+.EXTERNALMODULEDEPENDENCIES
+
+.REQUIREDSCRIPTS
+
+.EXTERNALSCRIPTDEPENDENCIES
+
+.RELEASENOTES
+
+.PRIVATEDATA
+
+#>
+
+<#
+
+.DESCRIPTION
+ this is a test for a script that will be published remotely
+
+#>
+Param()
+
+
+
+# SIG # Begin signature block
+# MIIFbQYJKoZIhvcNAQcCoIIFXjCCBVoCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
+# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
+# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUhY04RvNe0Q8hliL7qS3/X9kr
+# QVugggMIMIIDBDCCAeygAwIBAgIQN+zCRZRKiphJ5gGoRKvpeTANBgkqhkiG9w0B
+# AQsFADAaMRgwFgYDVQQDDA9Db2RlU2lnbmluZ0NlcnQwHhcNMjIwNjIyMTgyODUx
+# WhcNMjQwNjIyMTgzODUwWjAaMRgwFgYDVQQDDA9Db2RlU2lnbmluZ0NlcnQwggEi
+# MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCf7gQAR4AVpVc4/4OlffaEQ6uE
+# klG01+ga7sZbV7z9UkJFIDbntapCoXV85w/bNbmWSI+IUDisVBS7BIoicKagHskE
+# YhRJv6WL/zxD2lWP21MRkEJBEMicbrj38F2R/khGDq/T5/a1XH+7QVAsf1kOG/oU
+# d0CUDqgsR5+JdpaMt/QRM/jFLEUdvs+7zCvduciEEQRFFUbYYqy9RfmxMpPxZ6CM
+# RjLVr5k4tirbg1YyBK6l7xPvT3BUejGvEYPOdAskPXMVbMO37DyEszudqOz9eEvp
+# yHCKOgePLeq+9DbOQ+fAy30c79YNU5JfvgaDY+3c99WQXSeQuLYNDUeDDPGxAgMB
+# AAGjRjBEMA4GA1UdDwEB/wQEAwIHgDATBgNVHSUEDDAKBggrBgEFBQcDAzAdBgNV
+# HQ4EFgQUrmtlJTMGV5h8ksEMzPTPYk04g3IwDQYJKoZIhvcNAQELBQADggEBAAR3
+# sIiiVgSxUiPzGS/Ivwgjvqfsb6HXioE9VIJxQPwXc63LqC01TGJpeGayjr5zQ4p5
+# vt9q8WsiZvoUMofWzabz4BdprGWVDrO8hwksIixF8ojbfLuAra1cZ4qkDZtJH2Sn
+# 0dUhvXabZqLuVghMiyqcSvs2hN8OiVI+tLzW8VQKzbFdj77c+lHxKBTkcKVpLiSI
+# V2V8P4zRxyYE+CMlpTr58ErOGVxP1zITou7fwCAXdWEKWo5nlU22VNF6oGE9tghm
+# S3M5PQT8lFCjZOPPKx+0oLDxwjluHENXZzH+61ugrszzRjK1rG3D3emrRYh/4BcG
+# Wy7J1H41povt21JlzEExggHPMIIBywIBATAuMBoxGDAWBgNVBAMMD0NvZGVTaWdu
+# aW5nQ2VydAIQN+zCRZRKiphJ5gGoRKvpeTAJBgUrDgMCGgUAoHgwGAYKKwYBBAGC
+# NwIBDDEKMAigAoAAoQKAADAZBgkqhkiG9w0BCQMxDAYKKwYBBAGCNwIBBDAcBgor
+# BgEEAYI3AgELMQ4wDAYKKwYBBAGCNwIBFTAjBgkqhkiG9w0BCQQxFgQUbfriqhB/
+# EKzgoXnVu2UFtaTb040wDQYJKoZIhvcNAQEBBQAEggEAiQa/HUhDP1HyrPh7mC5H
+# 6IwOdxL4p3EIkGeuUh3ZqWRNFLNz0ob24vqmKBtaKTfJqqrxTIBYeoBKB3Y8Wcx2
+# rEaH31WqQM2U7mFvM2cVv6dcrdWmLcMwi3LSEMxJf6VbWpbmWZK6zMRW2H76P5wQ
+# cs6BUOwKZq/5eQcQLjJ3h+Mh5dsENZ7scB4U1yihD7Ggvrgxf54+J/TS8XuDsx2o
+# g0czxIjMBwT5wGh8BqbC50izZ3D0WRFe7UNnhMk7zKG/bvIRBxah+JV25hdoGYaR
+# 2tdmgr4EMPoB1ti8DOFmYAicckDWfX7/X4NzeM234LSMLtOxO2lVj5jhkmJJdjKh
+# WA==
+# SIG # End signature block
\ No newline at end of file
diff --git a/Test/testFiles/testScripts/ScriptWithoutEmptyLinesBetweenCommentBlocks.ps1 b/Test/testFiles/testScripts/ScriptWithoutEmptyLinesBetweenCommentBlocks.ps1
new file mode 100644
index 0000000..8d8d2aa
--- /dev/null
+++ b/Test/testFiles/testScripts/ScriptWithoutEmptyLinesBetweenCommentBlocks.ps1
@@ -0,0 +1,24 @@
+
+<#PSScriptInfo
+.VERSION 1.0
+.GUID 3951be04-bd06-4337-8dc3-a620bf539fbd
+.AUTHOR annavied
+.COMPANYNAME
+.COPYRIGHT
+.TAGS
+.LICENSEURI
+.PROJECTURI
+.ICONURI
+.EXTERNALMODULEDEPENDENCIES
+.REQUIREDSCRIPTS
+.EXTERNALSCRIPTDEPENDENCIES
+.RELEASENOTES
+.PRIVATEDATA
+#>
+<#
+
+.DESCRIPTION
+ this is a test for a script that will be published remotely
+
+#>
+Param()
diff --git a/Test/testFiles/testScripts/ScriptWithoutEmptyLinesInMetadata.ps1 b/Test/testFiles/testScripts/ScriptWithoutEmptyLinesInMetadata.ps1
new file mode 100644
index 0000000..2b28db6
--- /dev/null
+++ b/Test/testFiles/testScripts/ScriptWithoutEmptyLinesInMetadata.ps1
@@ -0,0 +1,23 @@
+
+<#PSScriptInfo
+.VERSION 1.0
+.GUID 3951be04-bd06-4337-8dc3-a620bf539fbd
+.AUTHOR annavied
+.COMPANYNAME
+.COPYRIGHT
+.TAGS
+.LICENSEURI
+.PROJECTURI
+.ICONURI
+.EXTERNALMODULEDEPENDENCIES
+.REQUIREDSCRIPTS
+.EXTERNALSCRIPTDEPENDENCIES
+.RELEASENOTES
+.PRIVATEDATA
+#>
+
+<#
+.DESCRIPTION
+ this is a test for a script that will be published remotely
+#>
+Param()
diff --git a/Test/testRepositories.xml b/Test/testRepositories.xml
new file mode 100644
index 0000000..1e330dd
--- /dev/null
+++ b/Test/testRepositories.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/owners.txt b/owners.txt
new file mode 100644
index 0000000..3e3f725
--- /dev/null
+++ b/owners.txt
@@ -0,0 +1,16 @@
+; this is an example owners.txt file which can be added at any level in the repo to indicate owners of a subtree
+; this file is used by ownership enforcer to determine reviewers to add to a pull request
+; you can add comments using ; as prefix
+; introduce each owner in a separate line with his/her alias (not email address)
+; prefixing an alias with * means that the owner will not be automatically added as a reviewer to pull requests to reduce noise, but can still be manually added and can sign off if necessary
+; to learn more you can read https://microsoft.sharepoint.com/teams/WAG/EngSys/EngPipeline/cdp/SitePages/Configure%20checkin%20gates.aspx
+; if you do not wish to use this feature then you can delete this file
+; example (pretend the following lines are not commented):
+;
+; developer1
+; developer2
+; *developer3
+annavied
+americks
+adityap
+*slee
\ No newline at end of file
diff --git a/src/PowerShellGetCompat.psd1 b/src/PowerShellGet.psd1
similarity index 51%
rename from src/PowerShellGetCompat.psd1
rename to src/PowerShellGet.psd1
index eca0d7c..ccab244 100644
--- a/src/PowerShellGetCompat.psd1
+++ b/src/PowerShellGet.psd1
@@ -1,5 +1,5 @@
#
-# Module manifest for module 'PowerShellGetCompat'
+# Module manifest for module 'PowerShellGet'
#
# Generated by: americks
#
@@ -7,40 +7,15 @@
#
@{
- RootModule = 'PowerShellGetCompat.psm1'
- ModuleVersion = '0.0.1'
+ RootModule = 'PowerShellGet.psm1'
+ ModuleVersion = '3.0.23'
GUID = '68ec3ec1-55bf-42f8-9add-d224e5c76548'
Author = 'Microsoft Corporation'
CompanyName = 'Microsoft Corporation'
Copyright = '(c) Microsoft Corporation. All rights reserved.'
- Description = 'PowerShellGetCompat is a compatibility module that allows use of PowerShellGet 2.x (and below) cmdlet syntax with PowerShellGet 3.0 (and newer) functionality by making a best effort mapping between the cmdlet interfaces of both versions of the module.'
+ Description = 'PowerShellGet is a compatibility module that allows use of PowerShellGet 2.x (and below) cmdlet syntax with PSResourceGet functionality by making a best effort mapping between the cmdlet interfaces of both versions of the module.'
PowerShellVersion = '3.0'
FunctionsToExport = @(
- "Find-CommandProxy",
- "Find-DscResourceProxy",
- "Find-ModuleProxy",
- "Find-RoleCapabilityProxy",
- "Find-ScriptProxy",
- "Get-InstalledModuleProxy",
- "Get-InstalledScriptProxy",
- "Get-PSRepositoryProxy",
- "Install-ModuleProxy",
- "Install-ScriptProxy",
- "Publish-ModuleProxy",
- "Publish-ScriptProxy",
- "Register-PSRepositoryProxy",
- "Save-ModuleProxy",
- "Save-ScriptProxy",
- "Set-PSRepositoryProxy",
- "Uninstall-ModuleProxy",
- "Uninstall-ScriptProxy",
- "Unregister-PSRepositoryProxy",
- "Update-ModuleProxy",
- "Update-ScriptProxy"
- )
- CmdletsToExport = @()
- VariablesToExport = '*'
- AliasesToExport = @(
"Find-Command",
"Find-DscResource",
"Find-Module",
@@ -63,9 +38,13 @@
"Update-Module",
"Update-Script"
)
+ CmdletsToExport = @()
+ VariablesToExport = '*'
+ AliasesToExport = @()
PrivateData = @{
PSData = @{
+ Prerelease = 'beta23'
Tags = @('PackageManagement',
'PSEdition_Desktop',
'PSEdition_Core',
@@ -73,14 +52,19 @@
'Mac',
'Windows')
- LicenseUri = 'https://github.com/PowerShell/PowerShellGetCompat/blob/master/LICENSE'
- ProjectUri = 'https://github.com/PowerShell/PowerShellGetCompat'
+ LicenseUri = 'https://github.com/PowerShell/PowerShellGet/blob/master/LICENSE'
+ ProjectUri = 'https://github.com/PowerShell/PowerShellGet'
ReleaseNotes = @'
-### 0.0.1
-* Initial release
+### 3.0.23-beta23
+* Changes
+- Add internal hook for PSResourceGet telemetry
+
+### 3.0.22-beta22
+* Changes
+- This module was renamed from 'CompatPowerShellGet' to 'PowerShellGet'
## For full history of release notes see changelog:
-https://github.com/PowerShell/PowerShellGetCompat/blob/master/CHANGELOG.md
+https://github.com/PowerShell/PowerShellGet/blob/master/CHANGELOG.md
'@
}
}
diff --git a/src/PowerShellGet.psm1 b/src/PowerShellGet.psm1
new file mode 100644
index 0000000..c50b024
--- /dev/null
+++ b/src/PowerShellGet.psm1
@@ -0,0 +1,3219 @@
+# PROXY HELPER
+# used to determine if we have a semantic version
+$semVerRegex = '^(?0|[1-9]\d*)\.(?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:-(?(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'
+
+# try to convert the string into a version (semantic or system)
+function Get-VersionType
+{
+ param ( $versionString )
+
+ # if this can be converted into a version, simple return it
+ $version = $versionString -as [version]
+ if ( $version ) {
+ return $version
+ }
+
+ # if the string matches a semantic version, return it, but also return a lossy conversion to system.version
+ if ( $versionString -match $semVerRegex ) {
+ return [pscustomobject]@{
+ Major = [int]$Matches['major']
+ Minor = [int]$Matches['Minor']
+ Patch = [int]$Matches['patch']
+ PreReleaseLabel = [string]$matches['prerelease']
+ BuildLabel = [string]$matches['buildmetadata']
+ originalString = $versionString
+ Version = [version]("{0}.{1}.{2}" -f $Matches['major'],$Matches['minor'],$Matches['patch'])
+ }
+ }
+ return $null
+}
+
+# this handles comparison of version with semantic versions
+# this is all needed as semantic version exists only in core
+function Compare-Version
+{
+ param ([string]$minimum, [string]$maximum)
+
+ # this is done so we can use version to do our comparison
+ $reference = Get-VersionType $minimum
+ if ( ! $reference ) {
+ throw "Cannot convert '$minimum' to version type"
+ }
+ $difference= Get-VersionType $maximum
+ if ( ! $difference ) {
+ throw "Cannot convert '$maximum' to version type"
+ }
+
+ if ( $reference -is [version] -and $difference -is [version] ) {
+ if ( $reference -gt $difference ) {
+ return 1
+ }
+ elseif ( $reference -lt $difference ) {
+ return -1
+ }
+ }
+ elseif ( $reference.version -is [version] -and $difference.version -is [version] ) {
+ # two semantic versions
+ if ( $reference.version -gt $difference.version ) {
+ return 1
+ }
+ elseif ( $reference.version -lt $difference.version ) {
+ return -1
+ }
+ }
+ elseif ( $reference -is [version] -and $difference.version -is [version] ) {
+ # one semantic version
+ if ( $reference -gt $difference.version ) {
+ return 1
+ }
+ elseif ( $reference -lt $difference.version ) {
+ return -1
+ }
+ elseif ( $reference -eq $difference.version ) {
+ # 1.0.0 is greater than 1.0.0-preview
+ return 1
+ }
+ }
+ elseif ( $reference.version -is [version] -and $difference -is [version] ) {
+ # one semantic version
+ if ( $reference.version -gt $difference ) {
+ return 1
+ }
+ elseif ( $reference.version -lt $difference ) {
+ return -1
+ }
+ elseif ( $reference.version -eq $difference ) {
+ # 1.0.0 is greater than 1.0.0-preview
+ return -1
+ }
+ }
+ # Fall through
+
+ if ( $reference.PreReleaseLabel -gt $difference.PreReleaseLabel ) {
+ return 1
+ }
+ if ( $reference.PreReleaseLabel -lt $difference.PreReleaseLabel ) {
+ return -1
+ }
+ # Fall through
+
+ if ( $reference.BuildLabel -gt $difference.BuildLabel ) {
+ return 1
+ }
+ if ( $reference.BuildLabel -lt $difference.BuildLabel ) {
+ return -1
+ }
+
+ # Fall through, they are equivalent
+ return 0
+}
+
+# Convert-VersionParamaters -RequiredVersion $RequiredVersion -MinimumVersion $MinimumVersion -MaximumVersion $MaximumVersion
+# this tries to figure out whether we have an improper use of version parameters
+# such as RequiredVersion with MinimumVersion or MaximumVersion
+function Convert-VersionParamaters
+{
+ param ( $RequiredVersion, $MinimumVersion, $MaximumVersion )
+
+ # validate that required is not used with minimum or maximum version
+ if ( $RequiredVersion -and ($MinimumVersion -or $MaximumVersion) ) {
+ throw "RequiredVersion may not be used with MinimumVersion or MaximumVersion"
+ }
+ elseif ( ! $RequiredVersion -and ! $MinimumVersion -and ! $MaximumVersion ) {
+ return $null
+ }
+ elseif ( $RequiredVersion -and ! $MinimumVersion -and ! $MaximumVersion ) {
+ return "$RequiredVersion" }
+
+ # now return the appropriate string
+ if ( $MinimumVersion -and ! $MaximumVersion ) {
+ return "[$MinimumVersion,)"
+ }
+ elseif ( ! $MinimumVersion -and $MaximumVersion ) {
+ # no minimum version
+ return "(,${MaximumVersion}]"
+ }
+ else {
+ $result = Compare-Version $MinimumVersion $MaximumVersion
+ if ( $result -ge 0 ) {
+ throw "'$MaximumVersion' must be greater than '$MinimumVersion'"
+ }
+
+ return "[${MinimumVersion},${MaximumVersion}]"
+ }
+}
+
+####
+####
+# Proxy functions
+# This is where we map the parameters from v2 to v3
+# In some cases we have the same parameters
+# In some cases we have parameters which are not used in v3 - these we will silently ignore
+# the goal in ignoring them is to provide ways for automation to succeed without error rather than provide exact
+# semantic behavior between v2 and v3
+# In some cases we have a way to map a v2 parameter into a v3 parameter
+# In those cases, we need to remove the parameter from the bound parameters and apply the value to the newly mapped parameter
+# In some cases we have a completely new parameter which we need to set.
+####
+####
+function Find-Command {
+[CmdletBinding(HelpUri='https://go.microsoft.com/fwlink/?LinkId=733636')]
+param(
+ [Parameter(Position=0)]
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Name},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${ModuleName},
+
+ [ValidateNotNull()]
+ [string]
+ ${MinimumVersion},
+
+ [ValidateNotNull()]
+ [string]
+ ${MaximumVersion},
+
+ [ValidateNotNull()]
+ [string]
+ ${RequiredVersion},
+
+ [switch]
+ ${AllVersions},
+
+ [switch]
+ ${AllowPrerelease},
+
+ [ValidateNotNull()]
+ [string[]]
+ ${Tag},
+
+ [ValidateNotNull()]
+ [string]
+ ${Filter},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [uri]
+ ${Proxy},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${ProxyCredential},
+
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Repository})
+
+ begin
+ {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
+ {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+
+ # PARAMETER MAP
+ # Parameter translations
+ if ( $PSBoundParameters['Name'] ) { $null = $PSBoundParameters.Remove('Name'); $PSBoundParameters['CommandName'] = $Name }
+ if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
+ # Parameter Deletions (unsupported in v3)
+ if ( $PSBoundParameters['ModuleName'] ) { $null = $PSBoundParameters.Remove('ModuleName') }
+ if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion') }
+ if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion') }
+ if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion') }
+ if ( $PSBoundParameters['AllVersions'] ) { $null = $PSBoundParameters.Remove('AllVersions') }
+ if ( $PSBoundParameters['Tag'] ) { $null = $PSBoundParameters.Remove('Tag') }
+ if ( $PSBoundParameters['Filter'] ) { $null = $PSBoundParameters.Remove('Filter') }
+ if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
+ if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
+ # END PARAMETER MAP
+
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Find-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters }
+
+ # Set internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $true)
+ } catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ throw
+ }
+ }
+
+ process
+ {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ throw
+ }
+ }
+
+ end
+ {
+ try {
+
+ # Reset internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $false)
+ }
+ catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline.End()
+ } catch {
+ throw
+ }
+ }
+ <#
+ .ForwardHelpTargetName Find-Command
+ .ForwardHelpCategory Function
+ #>
+}
+
+function Find-DscResource {
+[CmdletBinding(HelpUri='https://go.microsoft.com/fwlink/?LinkId=517196')]
+param(
+ [Parameter(Position=0)]
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Name},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${ModuleName},
+
+ [ValidateNotNull()]
+ [string]
+ ${MinimumVersion},
+
+ [ValidateNotNull()]
+ [string]
+ ${MaximumVersion},
+
+ [ValidateNotNull()]
+ [string]
+ ${RequiredVersion},
+
+ [switch]
+ ${AllVersions},
+
+ [switch]
+ ${AllowPrerelease},
+
+ [ValidateNotNull()]
+ [string[]]
+ ${Tag},
+
+ [ValidateNotNull()]
+ [string]
+ ${Filter},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [uri]
+ ${Proxy},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${ProxyCredential},
+
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Repository})
+
+ begin
+ {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
+ {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+
+ # PARAMETER MAP
+ # Parameter translations
+ if ( $PSBoundParameters['Name'] ) { $null = $PSBoundParameters.Remove('Name'); $PSBoundParameters['DscResourceName'] = $Name }
+ if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
+ # Parameter Deletions (unsupported in v3)
+ if ( $PSBoundParameters['ModuleName'] ) { $null = $PSBoundParameters.Remove('ModuleName') }
+ if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion') }
+ if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion') }
+ if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion') }
+ if ( $PSBoundParameters['AllVersions'] ) { $null = $PSBoundParameters.Remove('AllVersions') }
+ if ( $PSBoundParameters['Tag'] ) { $null = $PSBoundParameters.Remove('Tag') }
+ if ( $PSBoundParameters['Filter'] ) { $null = $PSBoundParameters.Remove('Filter') }
+ if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
+ if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
+ # END PARAMETER MAP
+
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Find-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters }
+
+ # Set internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $true)
+ } catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ throw
+ }
+ }
+
+ process
+ {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ throw
+ }
+ }
+
+ end
+ {
+ try {
+ # Reset internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $false)
+ }
+ catch {
+ # Ignore if not available
+ }
+ $steppablePipeline.End()
+ }
+ catch {
+ throw
+ }
+ }
+ <#
+ .ForwardHelpTargetName Find-DscResource
+ .ForwardHelpCategory Function
+ #>
+}
+
+function Find-Module {
+[CmdletBinding(HelpUri='https://go.microsoft.com/fwlink/?LinkID=398574')]
+param(
+ [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Name},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${MinimumVersion},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${MaximumVersion},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${RequiredVersion},
+
+ [switch]
+ ${AllVersions},
+
+ [switch]
+ ${IncludeDependencies},
+
+ [ValidateNotNull()]
+ [string]
+ ${Filter},
+
+ [ValidateNotNull()]
+ [string[]]
+ ${Tag},
+
+ [ValidateSet('DscResource','Cmdlet','Function','RoleCapability')]
+ [ValidateNotNull()]
+ [string[]]
+ ${Includes},
+
+ [ValidateNotNull()]
+ [string[]]
+ ${DscResource},
+
+ [ValidateNotNull()]
+ [string[]]
+ ${RoleCapability},
+
+ [ValidateNotNull()]
+ [string[]]
+ ${Command},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [uri]
+ ${Proxy},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${ProxyCredential},
+
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Repository},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${Credential},
+
+ [switch]
+ ${AllowPrerelease})
+
+ begin
+ {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
+ {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+
+ # PARAMETER MAP
+ # add new specifier
+ $PSBoundParameters['Type'] = 'module'
+ # Parameter translations
+ $verArgs = @{}
+ if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion'); $verArgs['MinimumVersion'] = $MinimumVersion }
+ if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
+ if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
+ $ver = Convert-VersionParamaters @verArgs
+ if ( $ver ) {
+ $PSBoundParameters['Version'] = $ver
+ }
+ if ( $PSBoundParameters['AllVersions'] ) { $null = $PSBoundParameters.Remove('AllVersions'); $PSBoundParameters['Version'] = '*' }
+ if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
+ # Parameter Deletions (unsupported in v3)
+ if ( $PSBoundParameters['Filter'] ) { $null = $PSBoundParameters.Remove('Filter') }
+ if ( $PSBoundParameters['Includes'] ) { $null = $PSBoundParameters.Remove('Includes') }
+ if ( $PSBoundParameters['DscResource'] ) { $null = $PSBoundParameters.Remove('DscResource'); }
+ if ( $PSBoundParameters['RoleCapability'] ) { $null = $PSBoundParameters.Remove('RoleCapability'); }
+ if ( $PSBoundParameters['Command'] ) { $null = $PSBoundParameters.Remove('Command'); }
+ if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
+ if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
+ # END PARAMETER MAP
+
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Find-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters }
+
+ # Set internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $true)
+ } catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ throw
+ }
+ }
+
+ process
+ {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ throw
+ }
+ }
+
+ end
+ {
+ try {
+ # Reset internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $false)
+ }
+ catch {
+ # Ignore if not available
+ }
+ $steppablePipeline.End()
+ } catch {
+ throw
+ }
+ }
+ <#
+ .ForwardHelpTargetName Find-Module
+ .ForwardHelpCategory Function
+ #>
+}
+
+function Find-RoleCapability {
+[CmdletBinding(HelpUri='https://go.microsoft.com/fwlink/?LinkId=718029')]
+param(
+ [Parameter(Position=0)]
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Name},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${ModuleName},
+
+ [ValidateNotNull()]
+ [string]
+ ${MinimumVersion},
+
+ [ValidateNotNull()]
+ [string]
+ ${MaximumVersion},
+
+ [ValidateNotNull()]
+ [string]
+ ${RequiredVersion},
+
+ [switch]
+ ${AllVersions},
+
+ [switch]
+ ${AllowPrerelease},
+
+ [ValidateNotNull()]
+ [string[]]
+ ${Tag},
+
+ [ValidateNotNull()]
+ [string]
+ ${Filter},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [uri]
+ ${Proxy},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${ProxyCredential},
+
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Repository})
+
+ begin
+ {
+ # Find-RoleCability is no longer supported
+ Write-Warning -Message "The cmdlet 'Find-RoleCapability' is deprecated."
+ }
+ <#
+ .ForwardHelpTargetName Find-RoleCapability
+ .ForwardHelpCategory Function
+ #>
+}
+
+function Find-Script {
+[CmdletBinding(HelpUri='https://go.microsoft.com/fwlink/?LinkId=619785')]
+param(
+ [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Name},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${MinimumVersion},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${MaximumVersion},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${RequiredVersion},
+
+ [switch]
+ ${AllVersions},
+
+ [switch]
+ ${IncludeDependencies},
+
+ [ValidateNotNull()]
+ [string]
+ ${Filter},
+
+ [ValidateNotNull()]
+ [string[]]
+ ${Tag},
+
+ [ValidateSet('Function','Workflow')]
+ [ValidateNotNull()]
+ [string[]]
+ ${Includes},
+
+ [ValidateNotNull()]
+ [string[]]
+ ${Command},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [uri]
+ ${Proxy},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${ProxyCredential},
+
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Repository},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${Credential},
+
+ [switch]
+ ${AllowPrerelease})
+
+ begin
+ {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
+ {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+
+ # PARAMETER MAP
+ # add new specifier
+ $PSBoundParameters['Type'] = 'script'
+ # Parameter translations
+ $verArgs = @{}
+ if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion'); $verArgs['MinimumVersion'] = $MinimumVersion }
+ if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
+ if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
+ $ver = Convert-VersionParamaters @verArgs
+ if ( $ver ) {
+ $PSBoundParameters['Version'] = $ver
+ }
+ if ( $PSBoundParameters['AllVersions'] ) { $null = $PSBoundParameters.Remove('AllVersions'); $PSBoundParameters['Version'] = '*' }
+ if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
+
+ # Parameter Deletions (unsupported in v3)
+ if ( $PSBoundParameters['Filter'] ) { $null = $PSBoundParameters.Remove('Filter') }
+ if ( $PSBoundParameters['Includes'] ) { $null = $PSBoundParameters.Remove('Includes') }
+ if ( $PSBoundParameters['Command'] ) { $null = $PSBoundParameters.Remove('Command') }
+ if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
+ if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
+ # END PARAMETER MAP
+
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Find-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters }
+
+ # Set internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $true)
+ } catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ throw
+ }
+ }
+
+ process
+ {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ throw
+ }
+ }
+
+ end
+ {
+ try {
+ # Reset internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $false)
+ }
+ catch {
+ # Ignore if not available
+ }
+ $steppablePipeline.End()
+ } catch {
+ throw
+ }
+ }
+ <#
+ .ForwardHelpTargetName Find-Script
+ .ForwardHelpCategory Function
+ #>
+}
+
+function Get-InstalledModule {
+[CmdletBinding(HelpUri='https://go.microsoft.com/fwlink/?LinkId=526863')]
+param(
+ [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Name},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${MinimumVersion},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${RequiredVersion},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${MaximumVersion},
+
+ [switch]
+ ${AllVersions},
+
+ [switch]
+ ${AllowPrerelease})
+
+ begin
+ {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
+ {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+
+ # PARAMETER MAP
+ # Parameter translations
+ $verArgs = @{}
+ if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion'); $verArgs['MinimumVersion'] = $MinimumVersion }
+ if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
+ if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
+ $ver = Convert-VersionParamaters @verArgs
+ if ( $ver ) {
+ $PSBoundParameters['Version'] = $ver
+ }
+ if ( $PSBoundParameters['AllVersions'] ) { $null = $PSBoundParameters.Remove('AllVersions'); $PSBoundParameters['Version'] = '*' }
+ if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
+ # END PARAMETER MAP
+
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Get-InstalledPSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters }
+
+ # Set internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $true)
+ } catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ throw
+ }
+ }
+
+ process
+ {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ throw
+ }
+ }
+
+ end
+ {
+ try {
+ # Reset internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $false)
+ }
+ catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline.End()
+ } catch {
+ throw
+ }
+ }
+ <#
+ .ForwardHelpTargetName Get-InstalledModule
+ .ForwardHelpCategory Function
+ #>
+}
+
+function Get-InstalledScript {
+[CmdletBinding(HelpUri='https://go.microsoft.com/fwlink/?LinkId=619790')]
+param(
+ [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Name},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${MinimumVersion},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${RequiredVersion},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${MaximumVersion},
+
+ [switch]
+ ${AllowPrerelease})
+
+ begin
+ {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
+ {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+
+ # PARAMETER MAP
+ # Parameter translations
+ $verArgs = @{}
+ if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion'); $verArgs['MinimumVersion'] = $MinimumVersion }
+ if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
+ if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
+ $ver = Convert-VersionParamaters @verArgs
+ if ( $ver ) {
+ $PSBoundParameters['Version'] = $ver
+ }
+ if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
+ # END PARAMETER MAP
+
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Get-InstalledPSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters }
+
+ # Set internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $true)
+ } catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ throw
+ }
+ }
+
+ process
+ {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ throw
+ }
+ }
+
+ end
+ {
+ try {
+ # Reset internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $false)
+ }
+ catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline.End()
+ } catch {
+ throw
+ }
+ }
+ <#
+ .ForwardHelpTargetName Get-InstalledScript
+ .ForwardHelpCategory Function
+ #>
+}
+
+function Get-PSRepository {
+[CmdletBinding(HelpUri='https://go.microsoft.com/fwlink/?LinkID=517127')]
+param(
+ [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Name})
+
+ begin
+ {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
+ {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Get-PSResourceRepository', [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters }
+
+ # Set internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $true)
+ } catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ throw
+ }
+ }
+
+ process
+ {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ throw
+ }
+ }
+
+ end
+ {
+ try {
+ # Reset internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $false)
+ }
+ catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline.End()
+ } catch {
+ throw
+ }
+ }
+ <#
+ .ForwardHelpTargetName Get-PSRepository
+ .ForwardHelpCategory Function
+ #>
+}
+
+function Install-Module {
+[CmdletBinding(DefaultParameterSetName='NameParameterSet', SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='https://go.microsoft.com/fwlink/?LinkID=398573')]
+param(
+ [Parameter(ParameterSetName='NameParameterSet', Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Name},
+
+ [Parameter(ParameterSetName='InputObject', Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [psobject[]]
+ ${InputObject},
+
+ [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${MinimumVersion},
+
+ [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${MaximumVersion},
+
+ [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${RequiredVersion},
+
+ [Parameter(ParameterSetName='NameParameterSet')]
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Repository},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${Credential},
+
+ [ValidateSet('CurrentUser','AllUsers')]
+ [string]
+ ${Scope},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [uri]
+ ${Proxy},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${ProxyCredential},
+
+ [switch]
+ ${AllowClobber},
+
+ [switch]
+ ${SkipPublisherCheck},
+
+ [switch]
+ ${Force},
+
+ [Parameter(ParameterSetName='NameParameterSet')]
+ [switch]
+ ${AllowPrerelease},
+
+ [switch]
+ ${AcceptLicense},
+
+ [switch]
+ ${PassThru})
+
+ begin
+ {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
+ {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+
+ # PARAMETER MAP
+ # Parameter translations
+ $verArgs = @{}
+ if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion'); $verArgs['MinimumVersion'] = $MinimumVersion }
+ if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
+ if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
+ $ver = Convert-VersionParamaters @verArgs
+ if ( $ver ) {
+ $PSBoundParameters['Version'] = $ver
+ }
+ if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
+ $PSBoundParameters['NoClobber'] = $true
+ if ( $PSBoundParameters['AllowClobber'] ) { $null = $PSBoundParameters.Remove('AllowClobber'); $PSBoundParameters['NoClobber'] = (-not $AllowClobber) }
+ $PSBoundParameters['AuthenticodeCheck'] = $true
+ if ( $PSBoundParameters['SkipPublisherCheck'] ) { $null = $PSBoundParameters.Remove('SkipPublisherCheck'); $PSBoundParameters['AuthenticodeCheck'] = (-not $SkipPublisherCheck) }
+ # Parameter Deletions (unsupported in v3)
+ if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
+ if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
+ if ( $PSBoundParameters['Force'] ) { $null = $PSBoundParameters.Remove('Force') }
+ # END PARAMETER MAP
+
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Install-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters }
+
+ # Set internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $true)
+ } catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ throw
+ }
+ }
+
+ process
+ {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ throw
+ }
+ }
+
+ end
+ {
+ try {
+ # Reset internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $false)
+ }
+ catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline.End()
+ } catch {
+ throw
+ }
+ }
+ <#
+ .ForwardHelpTargetName Install-Module
+ .ForwardHelpCategory Function
+ #>
+}
+
+function Install-Script {
+[CmdletBinding(DefaultParameterSetName='NameParameterSet', SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='https://go.microsoft.com/fwlink/?LinkId=619784')]
+param(
+ [Parameter(ParameterSetName='NameParameterSet', Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Name},
+
+ [Parameter(ParameterSetName='InputObject', Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [psobject[]]
+ ${InputObject},
+
+ [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${MinimumVersion},
+
+ [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${MaximumVersion},
+
+ [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${RequiredVersion},
+
+ [Parameter(ParameterSetName='NameParameterSet')]
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Repository},
+
+ [ValidateSet('CurrentUser','AllUsers')]
+ [string]
+ ${Scope},
+
+ [switch]
+ ${NoPathUpdate},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [uri]
+ ${Proxy},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${ProxyCredential},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${Credential},
+
+ [switch]
+ ${Force},
+
+ [Parameter(ParameterSetName='NameParameterSet')]
+ [switch]
+ ${AllowPrerelease},
+
+ [switch]
+ ${AcceptLicense},
+
+ [switch]
+ ${PassThru})
+
+ begin
+ {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
+ {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+
+ # PARAMETER MAP
+ # Parameter translations
+ $verArgs = @{}
+ if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion'); $verArgs['MinimumVersion'] = $MinimumVersion }
+ if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
+ if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
+ $ver = Convert-VersionParamaters @verArgs
+ if ( $ver ) {
+ $PSBoundParameters['Version'] = $ver
+ }
+ if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
+ # Parameter Deletions (unsupported in v3)
+ if ( $PSBoundParameters['NoPathUpdate'] ) { $null = $PSBoundParameters.Remove('NoPathUpdate') }
+ if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
+ if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
+ if ( $PSBoundParameters['Force'] ) { $null = $PSBoundParameters.Remove('Force') }
+ # END PARAMETER MAP
+
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Install-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters }
+
+ # Set internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $true)
+ } catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ throw
+ }
+ }
+
+ process
+ {
+ try {
+ # Reset internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $false)
+ }
+ catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline.Process($_)
+ } catch {
+ throw
+ }
+ }
+
+ end
+ {
+ try {
+ $steppablePipeline.End()
+ } catch {
+ throw
+ }
+ }
+ <#
+ .ForwardHelpTargetName Install-Script
+ .ForwardHelpCategory Function
+ #>
+}
+
+function New-ScriptFileInfo {
+[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess=$true, HelpUri='https://go.microsoft.com/fwlink/?LinkId=619792')]
+param(
+ [Parameter(Position=0, Mandatory=$false, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${Path},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${Version},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${Author},
+
+ [Parameter(Mandatory=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${Description},
+
+ [ValidateNotNullOrEmpty()]
+ [Guid]
+ ${Guid},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${CompanyName},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${Copyright},
+
+ [ValidateNotNullOrEmpty()]
+ [Object[]]
+ ${RequiredModules},
+
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${ExternalModuleDependencies},
+
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${RequiredScripts},
+
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${ExternalScriptDependencies},
+
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Tags},
+
+ [ValidateNotNullOrEmpty()]
+ [Uri]
+ ${ProjectUri},
+
+ [ValidateNotNullOrEmpty()]
+ [Uri]
+ ${LicenseUri},
+
+ [ValidateNotNullOrEmpty()]
+ [Uri]
+ ${IconUri},
+
+ [string[]]
+ ${ReleaseNotes},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${PrivateData},
+
+ [switch]
+ ${PassThru},
+
+ [switch]
+ ${Force})
+
+ begin
+ {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
+ {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+
+ # PARAMETER MAP
+ # Parameter translations
+ if ( !$PSBoundParameters['Path'] ) {
+ $RandomScriptPath = Join-Path -Path . -ChildPath "$(Get-Random).ps1";
+ $PSBoundParameters['Path'] = $RandomScriptPath
+ }
+ # Translate from string[] to string
+ if ( $PSBoundParameters['ReleaseNotes'] ) {
+ $PSBoundParameters['ReleaseNotes'] = $PSBoundParameters['ReleaseNotes'] -join "; "
+ }
+ # Parameter Deletions (unsupported in v3)
+ if ( $PSBoundParameters['PassThru'] ) { $null = $PSBoundParameters.Remove('PassThru') }
+ # END PARAMETER MAP
+
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('New-PSScriptFileInfo', [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters }
+
+ # Set internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $true)
+ } catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ throw
+ }
+ }
+
+ process
+ {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ throw
+ }
+ }
+
+ end
+ {
+ try {
+ # Reset internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $false)
+ }
+ catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline.End()
+ } catch {
+ throw
+ }
+ }
+ <#
+ .ForwardHelpTargetName Test-ScriptFileInfo
+ .ForwardHelpCategory Function
+ #>
+}
+
+function Publish-Module {
+[CmdletBinding(DefaultParameterSetName='ModuleNameParameterSet', SupportsShouldProcess=$true, ConfirmImpact='Medium', PositionalBinding=$false, HelpUri='https://go.microsoft.com/fwlink/?LinkID=398575')]
+param(
+ [Parameter(ParameterSetName='ModuleNameParameterSet', Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${Name},
+
+ [Parameter(ParameterSetName='ModulePathParameterSet', Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${Path},
+
+ [Parameter(ParameterSetName='ModuleNameParameterSet')]
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${RequiredVersion},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${NuGetApiKey},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${Repository},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${Credential},
+
+ [version]
+ ${FormatVersion},
+
+ [string[]]
+ ${ReleaseNotes},
+
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Tags},
+
+ [ValidateNotNullOrEmpty()]
+ [uri]
+ ${LicenseUri},
+
+ [ValidateNotNullOrEmpty()]
+ [uri]
+ ${IconUri},
+
+ [ValidateNotNullOrEmpty()]
+ [uri]
+ ${ProjectUri},
+
+ [Parameter(ParameterSetName='ModuleNameParameterSet')]
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Exclude},
+
+ [switch]
+ ${Force},
+
+ [Parameter(ParameterSetName='ModuleNameParameterSet')]
+ [switch]
+ ${AllowPrerelease},
+
+ [switch]
+ ${SkipAutomaticTags})
+
+ begin
+ {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
+ {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+
+ # PARAMETER MAP
+ # Parameter translations
+ if ( $PSBoundParameters['NuGetApiKey'] ) { $null = $PSBoundParameters.Remove('NuGetApiKey'); $PSBoundParameters['APIKey'] = $NuGetApiKey }
+ # Parameter Deletions (unsupported in v3)
+ if ( $PSBoundParameters['Name'] ) { $null = $PSBoundParameters.Remove('Name') }
+ if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion') }
+ if ( $PSBoundParameters['FormatVersion'] ) { $null = $PSBoundParameters.Remove('FormatVersion') }
+ if ( $PSBoundParameters['ReleaseNotes'] ) { $null = $PSBoundParameters.Remove('ReleaseNotes') }
+ if ( $PSBoundParameters['Tags'] ) { $null = $PSBoundParameters.Remove('Tags') }
+ if ( $PSBoundParameters['LicenseUri'] ) { $null = $PSBoundParameters.Remove('LicenseUri') }
+ if ( $PSBoundParameters['IconUri'] ) { $null = $PSBoundParameters.Remove('IconUri') }
+ if ( $PSBoundParameters['ProjectUri'] ) { $null = $PSBoundParameters.Remove('ProjectUri') }
+ if ( $PSBoundParameters['Exclude'] ) { $null = $PSBoundParameters.Remove('Exclude') }
+ if ( $PSBoundParameters['Force'] ) { $null = $PSBoundParameters.Remove('Force') }
+ if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease') }
+ if ( $PSBoundParameters['SkipAutomaticTags'] ) { $null = $PSBoundParameters.Remove('SkipAutomaticTags') }
+ # END PARAMETER MAP
+
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Publish-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters }
+
+ # Set internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $true)
+ } catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ throw
+ }
+ }
+
+ process
+ {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ throw
+ }
+ }
+
+ end
+ {
+ try {
+ # Reset internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $false)
+ }
+ catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline.End()
+ } catch {
+ throw
+ }
+ }
+ <#
+ .ForwardHelpTargetName Publish-Module
+ .ForwardHelpCategory Function
+ #>
+}
+
+function Publish-Script {
+[CmdletBinding(DefaultParameterSetName='PathParameterSet', SupportsShouldProcess=$true, ConfirmImpact='Medium', PositionalBinding=$false, HelpUri='https://go.microsoft.com/fwlink/?LinkId=619788')]
+param(
+ [Parameter(ParameterSetName='PathParameterSet', Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${Path},
+
+ [Parameter(ParameterSetName='LiteralPathParameterSet', Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
+ [Alias('PSPath')]
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${LiteralPath},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${NuGetApiKey},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${Repository},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${Credential},
+
+ [switch]
+ ${Force})
+
+ begin
+ {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
+ {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+
+ # PARAMETER MAP
+ # Parameter translations
+ if ( $PSBoundParameters['LiteralPath'] ) { $null = $PSBoundParameters.Remove('LiteralPath'); $PSBoundParameters['Path'] = $LiteralPath }
+ if ( $PSBoundParameters['NuGetApiKey'] ) { $null = $PSBoundParameters.Remove('NuGetApiKey'); $PSBoundParameters['APIKey'] = $NuGetApiKey }
+ # Parameter Deletions (unsupported in v3)
+ if ( $PSBoundParameters['Force'] ) { $null = $PSBoundParameters.Remove('Force') }
+ # END PARAMETER MAP
+
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Publish-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters }
+
+ # Set internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $true)
+ } catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ throw
+ }
+ }
+
+ process
+ {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ throw
+ }
+ }
+
+ end
+ {
+ try {
+ # Reset internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $false)
+ }
+ catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline.End()
+ } catch {
+ throw
+ }
+ }
+ <#
+ .ForwardHelpTargetName Publish-Script
+ .ForwardHelpCategory Function
+ #>
+}
+
+function Register-PSRepository {
+[CmdletBinding(DefaultParameterSetName='NameParameterSet', HelpUri='https://go.microsoft.com/fwlink/?LinkID=517129')]
+param(
+ [Parameter(ParameterSetName='NameParameterSet', Mandatory=$true, Position=0)]
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${Name},
+
+ [Parameter(ParameterSetName='NameParameterSet', Mandatory=$true, Position=1)]
+ [ValidateNotNullOrEmpty()]
+ [uri]
+ ${SourceLocation},
+
+ [Parameter(ParameterSetName='NameParameterSet')]
+ [ValidateNotNullOrEmpty()]
+ [uri]
+ ${PublishLocation},
+
+ [Parameter(ParameterSetName='NameParameterSet')]
+ [ValidateNotNullOrEmpty()]
+ [uri]
+ ${ScriptSourceLocation},
+
+ [Parameter(ParameterSetName='NameParameterSet')]
+ [ValidateNotNullOrEmpty()]
+ [uri]
+ ${ScriptPublishLocation},
+
+ [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${Credential},
+
+ [Parameter(ParameterSetName='PSGalleryParameterSet', Mandatory=$true)]
+ [switch]
+ ${Default},
+
+ [ValidateSet('Trusted','Untrusted')]
+ [string]
+ ${InstallationPolicy},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [uri]
+ ${Proxy},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${ProxyCredential},
+
+ [Parameter(ParameterSetName='NameParameterSet')]
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${PackageManagementProvider})
+
+ begin
+ {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
+ {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+
+ # PARAMETER MAP
+ # Parameter translations
+ if ( $PSBoundParameters['InstallationPolicy'] ) {
+ $null = $PSBoundParameters.Remove('InstallationPolicy')
+ if ( $InstallationPolicy -eq "Trusted" ) {
+ $PSBoundParameters['Trusted'] = $true
+ }
+ }
+ if ( $PSBoundParameters['SourceLocation'] ) { $null = $PSBoundParameters.Remove('SourceLocation'); $PSBoundParameters['Uri'] = $SourceLocation }
+ if ( $PSBoundParameters['Default'] ) { $null = $PSBoundParameters.Remove('Default'); $PSBoundParameters['PSGallery'] = $Default }
+ # Parameter Deletions (unsupported in v3)
+ if ( $PSBoundParameters['PublishLocation'] ) { $null = $PSBoundParameters.Remove('PublishLocation') }
+ if ( $PSBoundParameters['ScriptSourceLocation'] ) { $null = $PSBoundParameters.Remove('ScriptSourceLocation') }
+ if ( $PSBoundParameters['ScriptPublishLocation'] ) { $null = $PSBoundParameters.Remove('ScriptPublishLocation') }
+ if ( $PSBoundParameters['Credential'] ) { $null = $PSBoundParameters.Remove('Credential') }
+ if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
+ if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
+ if ( $PSBoundParameters['PackageManagementProvider'] ) { $null = $PSBoundParameters.Remove('PackageManagementProvider') }
+ # END PARAMETER MAP
+
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Register-PSResourceRepository', [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters }
+
+ # Set internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $true)
+ } catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ throw
+ }
+ }
+
+ process
+ {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ throw
+ }
+ }
+
+ end
+ {
+ try {
+ # Reset internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $false)
+ }
+ catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline.End()
+ } catch {
+ throw
+ }
+ }
+ <#
+ .ForwardHelpTargetName Register-PSRepository
+ .ForwardHelpCategory Function
+ #>
+}
+
+function Save-Module {
+[CmdletBinding(DefaultParameterSetName='NameAndPathParameterSet', SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='https://go.microsoft.com/fwlink/?LinkId=531351')]
+param(
+ [Parameter(ParameterSetName='NameAndLiteralPathParameterSet', Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
+ [Parameter(ParameterSetName='NameAndPathParameterSet', Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Name},
+
+ [Parameter(ParameterSetName='InputObjectAndLiteralPathParameterSet', Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
+ [Parameter(ParameterSetName='InputObjectAndPathParameterSet', Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [psobject[]]
+ ${InputObject},
+
+ [Parameter(ParameterSetName='NameAndLiteralPathParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [Parameter(ParameterSetName='NameAndPathParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${MinimumVersion},
+
+ [Parameter(ParameterSetName='NameAndLiteralPathParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [Parameter(ParameterSetName='NameAndPathParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${MaximumVersion},
+
+ [Parameter(ParameterSetName='NameAndLiteralPathParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [Parameter(ParameterSetName='NameAndPathParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${RequiredVersion},
+
+ [Parameter(ParameterSetName='NameAndLiteralPathParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [Parameter(ParameterSetName='NameAndPathParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Repository},
+
+ [Parameter(ParameterSetName='InputObjectAndPathParameterSet', Mandatory=$true, Position=1, ValueFromPipelineByPropertyName=$true)]
+ [Parameter(ParameterSetName='NameAndPathParameterSet', Mandatory=$true, Position=1, ValueFromPipelineByPropertyName=$true)]
+ [string]
+ ${Path},
+
+ [Parameter(ParameterSetName='InputObjectAndLiteralPathParameterSet', Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
+ [Parameter(ParameterSetName='NameAndLiteralPathParameterSet', Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
+ [Alias('PSPath')]
+ [string]
+ ${LiteralPath},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [uri]
+ ${Proxy},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${ProxyCredential},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${Credential},
+
+ [switch]
+ ${Force},
+
+ [Parameter(ParameterSetName='NameAndLiteralPathParameterSet')]
+ [Parameter(ParameterSetName='NameAndPathParameterSet')]
+ [switch]
+ ${AllowPrerelease},
+
+ [switch]
+ ${AcceptLicense})
+
+ begin
+ {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
+ {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+
+ # PARAMETER MAP
+ # Parameter translations
+ $verArgs = @{}
+ if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion'); $verArgs['MinimumVersion'] = $MaximumVersion }
+ if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
+ if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
+ $ver = Convert-VersionParamaters @verArgs
+ if ( $ver ) {
+ $PSBoundParameters['Version'] = $ver
+ }
+ if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
+ if ( $PSBoundParameters['LiteralPath'] ) { $null = $PSBoundParameters.Remove('LiteralPath'); $PSBoundParameters['Path'] = $LiteralPath }
+ # Parameter Deletions (unsupported in v3)
+ if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
+ if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
+ if ( $PSBoundParameters['Force'] ) { $null = $PSBoundParameters.Remove('Force') }
+ if ( $PSBoundParameters['AcceptLicense'] ) { $null = $PSBoundParameters.Remove('AcceptLicense') }
+ # END PARAMETER MAP
+
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Save-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters }
+
+ # Set internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $true)
+ } catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ throw
+ }
+ }
+
+ process
+ {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ throw
+ }
+ }
+
+ end
+ {
+ try {
+ # Reset internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $false)
+ }
+ catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline.End()
+ } catch {
+ throw
+ }
+ }
+ <#
+ .ForwardHelpTargetName Save-Module
+ .ForwardHelpCategory Function
+ #>
+}
+
+function Save-Script {
+[CmdletBinding(DefaultParameterSetName='NameAndPathParameterSet', SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='https://go.microsoft.com/fwlink/?LinkId=619786')]
+param(
+ [Parameter(ParameterSetName='NameAndLiteralPathParameterSet', Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
+ [Parameter(ParameterSetName='NameAndPathParameterSet', Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Name},
+
+ [Parameter(ParameterSetName='InputObjectAndLiteralPathParameterSet', Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
+ [Parameter(ParameterSetName='InputObjectAndPathParameterSet', Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [psobject[]]
+ ${InputObject},
+
+ [Parameter(ParameterSetName='NameAndLiteralPathParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [Parameter(ParameterSetName='NameAndPathParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${MinimumVersion},
+
+ [Parameter(ParameterSetName='NameAndLiteralPathParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [Parameter(ParameterSetName='NameAndPathParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${MaximumVersion},
+
+ [Parameter(ParameterSetName='NameAndLiteralPathParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [Parameter(ParameterSetName='NameAndPathParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${RequiredVersion},
+
+ [Parameter(ParameterSetName='NameAndLiteralPathParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [Parameter(ParameterSetName='NameAndPathParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Repository},
+
+ [Parameter(ParameterSetName='InputObjectAndPathParameterSet', Mandatory=$true, Position=1, ValueFromPipelineByPropertyName=$true)]
+ [Parameter(ParameterSetName='NameAndPathParameterSet', Mandatory=$true, Position=1, ValueFromPipelineByPropertyName=$true)]
+ [string]
+ ${Path},
+
+ [Parameter(ParameterSetName='InputObjectAndLiteralPathParameterSet', Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
+ [Parameter(ParameterSetName='NameAndLiteralPathParameterSet', Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
+ [Alias('PSPath')]
+ [string]
+ ${LiteralPath},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [uri]
+ ${Proxy},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${ProxyCredential},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${Credential},
+
+ [switch]
+ ${Force},
+
+ [Parameter(ParameterSetName='NameAndLiteralPathParameterSet')]
+ [Parameter(ParameterSetName='NameAndPathParameterSet')]
+ [switch]
+ ${AllowPrerelease},
+
+ [switch]
+ ${AcceptLicense})
+
+ begin
+ {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
+ {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+
+ # PARAMETER MAP
+ # Parameter translations
+ $verArgs = @{}
+ if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion'); $verArgs['MinimumVersion'] = $MaximumVersion }
+ if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
+ if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
+ $ver = Convert-VersionParamaters @verArgs
+ if ( $ver ) {
+ $PSBoundParameters['Version'] = $ver
+ }
+ if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
+ if ( $PSBoundParameters['LiteralPath'] ) { $null = $PSBoundParameters.Remove('LiteralPath'); $PSBoundParameters['Path'] = $LiteralPath }
+ # Parameter Deletions (unsupported in v3)
+ if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
+ if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
+ if ( $PSBoundParameters['Force'] ) { $null = $PSBoundParameters.Remove('Force') }
+ if ( $PSBoundParameters['AcceptLicense'] ) { $null = $PSBoundParameters.Remove('AcceptLicense') }
+
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Save-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters }
+
+ # Set internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $true)
+ } catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ throw
+ }
+ }
+
+ process
+ {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ throw
+ }
+ }
+
+ end
+ {
+ try {
+ # Reset internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $false)
+ }
+ catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline.End()
+ } catch {
+ throw
+ }
+ }
+ <#
+ .ForwardHelpTargetName Save-Script
+ .ForwardHelpCategory Function
+ #>
+}
+
+function Set-PSRepository {
+[CmdletBinding(PositionalBinding=$false, HelpUri='https://go.microsoft.com/fwlink/?LinkID=517128')]
+param(
+ [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${Name},
+
+ [Parameter(Position=1)]
+ [ValidateNotNullOrEmpty()]
+ [uri]
+ ${SourceLocation},
+
+ [ValidateNotNullOrEmpty()]
+ [uri]
+ ${PublishLocation},
+
+ [ValidateNotNullOrEmpty()]
+ [uri]
+ ${ScriptSourceLocation},
+
+ [ValidateNotNullOrEmpty()]
+ [uri]
+ ${ScriptPublishLocation},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${Credential},
+
+ [ValidateSet('Trusted','Untrusted')]
+ [string]
+ ${InstallationPolicy},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [uri]
+ ${Proxy},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${ProxyCredential},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${PackageManagementProvider})
+
+ begin
+ {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
+ {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+
+ # PARAMETER MAP
+ # Parameter translations
+ if ( $PSBoundParameters['InstallationPolicy'] ) {
+ $null = $PSBoundParameters.Remove('InstallationPolicy')
+ if ( $InstallationPolicy -eq "Trusted" ) {
+ $PSBoundParameters['Trusted'] = $true
+ }
+ else {
+ $PSBoundParameters['Trusted'] = $false
+ }
+ }
+ if ( $PSBoundParameters['SourceLocation'] ) { $null = $PSBoundParameters.Remove('SourceLocation'); $PSBoundParameters['Uri'] = $SourceLocation }
+ # Parameter Deletions (unsupported in v3)
+ if ( $PSBoundParameters['PublishLocation'] ) { $null = $PSBoundParameters.Remove('PublishLocation') }
+ if ( $PSBoundParameters['ScriptSourceLocation'] ) { $null = $PSBoundParameters.Remove('ScriptSourceLocation') }
+ if ( $PSBoundParameters['ScriptPublishLocation'] ) { $null = $PSBoundParameters.Remove('ScriptPublishLocation') }
+ if ( $PSBoundParameters['Credential'] ) { $null = $PSBoundParameters.Remove('Credential') }
+ if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
+ if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
+ if ( $PSBoundParameters['PackageManagementProvider'] ) { $null = $PSBoundParameters.Remove('PackageManagementProvider') }
+ # END PARAMETER MAP
+
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Set-PSResourceRepository', [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters }
+
+ # Set internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $true)
+ } catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ throw
+ }
+ }
+
+ process
+ {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ throw
+ }
+ }
+
+ end
+ {
+ try {
+ # Reset internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $false)
+ }
+ catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline.End()
+ } catch {
+ throw
+ }
+ }
+ <#
+ .ForwardHelpTargetName Set-PSRepository
+ .ForwardHelpCategory Function
+ #>
+}
+
+function Test-ScriptFileInfo {
+[CmdletBinding(PositionalBinding = $false, DefaultParameterSetName = 'PathParameterSet', HelpUri = 'https://go.microsoft.com/fwlink/?LinkId=619791')]
+param(
+ [Parameter(ParameterSetName='PathParameterSet', Position=0, Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${Path},
+
+ [Parameter(ParameterSetName='LiteralPathParameterSet', Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [Alias('PSPath')]
+ [string]
+ ${LiteralPath})
+
+ begin
+ {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
+ {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+
+ # PARAMETER MAP
+ # Parameter Deletions (unsupported in v3)
+ if ( $PSBoundParameters['LiteralPath'] ) { $null = $PSBoundParameters.Remove('LiteralPath'); $PSBoundParameters['Path'] = $LiteralPath }
+ # END PARAMETER MAP
+
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Test-PSScriptFileInfo', [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters }
+
+ # Set internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $true)
+ } catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ throw
+ }
+ }
+
+ process
+ {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ throw
+ }
+ }
+
+ end
+ {
+ try {
+ # Reset internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $false)
+ }
+ catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline.End()
+ } catch {
+ throw
+ }
+ }
+ <#
+ .ForwardHelpTargetName Test-ScriptFileInfo
+ .ForwardHelpCategory Function
+ #>
+}
+
+function Uninstall-Module {
+[CmdletBinding(DefaultParameterSetName='NameParameterSet', SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='https://go.microsoft.com/fwlink/?LinkId=526864')]
+param(
+ [Parameter(ParameterSetName='NameParameterSet', Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Name},
+
+ [Parameter(ParameterSetName='InputObject', Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [psobject[]]
+ ${InputObject},
+
+ [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${MinimumVersion},
+
+ [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${RequiredVersion},
+
+ [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${MaximumVersion},
+
+ [Parameter(ParameterSetName='NameParameterSet')]
+ [switch]
+ ${AllVersions},
+
+ [switch]
+ ${Force},
+
+ [Parameter(ParameterSetName='NameParameterSet')]
+ [switch]
+ ${AllowPrerelease})
+
+ begin
+ {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
+ {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+
+ # PARAMETER MAP
+ # Parameter translations
+ $verArgs = @{}
+ if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion'); $verArgs['MinimumVersion'] = $MinimumVersion }
+ if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
+ if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
+ $ver = Convert-VersionParamaters @verArgs
+ if ( $ver ) {
+ $PSBoundParameters['Version'] = $ver
+ }
+ if ( $PSBoundParameters['AllVersions'] ) { $null = $PSBoundParameters.Remove('AllVersions'); $PSBoundParameters['Version'] = '*' }
+ if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
+ # Parameter Deletions (unsupported in v3)
+ if ( $PSBoundParameters['Force'] ) { $null = $PSBoundParameters.Remove('Force') }
+ # END PARAMETER MAP
+
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Uninstall-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters }
+
+ # Set internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $true)
+ } catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ throw
+ }
+ }
+
+ process
+ {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ throw
+ }
+ }
+
+ end
+ {
+ try {
+ # Reset internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $false)
+ }
+ catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline.End()
+ } catch {
+ throw
+ }
+ }
+ <#
+ .ForwardHelpTargetName Uninstall-Module
+ .ForwardHelpCategory Function
+ #>
+}
+
+function Uninstall-Script {
+[CmdletBinding(DefaultParameterSetName='NameParameterSet', SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='https://go.microsoft.com/fwlink/?LinkId=619789')]
+param(
+ [Parameter(ParameterSetName='NameParameterSet', Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Name},
+
+ [Parameter(ParameterSetName='InputObject', Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [psobject[]]
+ ${InputObject},
+
+ [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${MinimumVersion},
+
+ [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${RequiredVersion},
+
+ [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${MaximumVersion},
+
+ [switch]
+ ${Force},
+
+ [Parameter(ParameterSetName='NameParameterSet')]
+ [switch]
+ ${AllowPrerelease})
+
+ begin
+ {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
+ {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+
+ # PARAMETER MAP
+ # Parameter translations
+ $verArgs = @{}
+ if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion'); $verArgs['MinimumVersion'] = $MinimumVersion }
+ if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
+ if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
+ $ver = Convert-VersionParamaters @verArgs
+ if ( $ver ) {
+ $PSBoundParameters['Version'] = $ver
+ }
+ if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
+ # Parameter Deletions (unsupported in v3)
+ if ( $PSBoundParameters['Force'] ) { $null = $PSBoundParameters.Remove('Force') }
+ # END PARAMETER MAP
+
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Uninstall-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters }
+
+ # Set internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $true)
+ } catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ throw
+ }
+ }
+
+ process
+ {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ throw
+ }
+ }
+
+ end
+ {
+ try {
+ # Reset internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $false)
+ }
+ catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline.End()
+ } catch {
+ throw
+ }
+ }
+ <#
+ .ForwardHelpTargetName Uninstall-Script
+ .ForwardHelpCategory Function
+ #>
+}
+
+function Unregister-PSRepository {
+[CmdletBinding(HelpUri='https://go.microsoft.com/fwlink/?LinkID=517130')]
+param(
+ [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Name})
+
+ begin
+ {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
+ {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+
+ # PARAMETER MAP
+ # No changes between Unregister-PSRepository and Unregister-PSResourceRepository
+ # END PARAMETER MAP
+
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Unregister-PSResourceRepository', [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters }
+
+ # Set internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $true)
+ } catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ throw
+ }
+ }
+
+ process
+ {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ throw
+ }
+ }
+
+ end
+ {
+ try {
+ # Reset internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $false)
+ }
+ catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline.End()
+ } catch {
+ throw
+ }
+ }
+ <#
+ .ForwardHelpTargetName Unregister-PSRepository
+ .ForwardHelpCategory Function
+ #>
+}
+
+function Update-Module {
+[CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='https://go.microsoft.com/fwlink/?LinkID=398576')]
+param(
+ [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Name},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${RequiredVersion},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${MaximumVersion},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${Credential},
+
+ [ValidateSet('CurrentUser','AllUsers')]
+ [string]
+ ${Scope},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [uri]
+ ${Proxy},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${ProxyCredential},
+
+ [switch]
+ ${Force},
+
+ [switch]
+ ${AllowPrerelease},
+
+ [switch]
+ ${AcceptLicense},
+
+ [switch]
+ ${PassThru})
+
+ begin
+ {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
+ {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+
+ # PARAMETER MAP
+ # Parameter translations
+ $verArgs = @{}
+ if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
+ if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
+ $ver = Convert-VersionParamaters @verArgs
+ if ( $ver ) {
+ $PSBoundParameters['Version'] = $ver
+ }
+ if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
+ # Parameter Deletions (unsupported in v3)
+ if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
+ if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
+ # END PARAMETER MAP
+
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Update-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters }
+
+ # Set internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $true)
+ } catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ throw
+ }
+ }
+
+ process
+ {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ throw
+ }
+ }
+
+ end
+ {
+ try {
+ # Reset internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $false)
+ }
+ catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline.End()
+ } catch {
+ throw
+ }
+ }
+ <#
+ .ForwardHelpTargetName Update-Module
+ .ForwardHelpCategory Function
+ #>
+}
+
+function Update-Script {
+[CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='https://go.microsoft.com/fwlink/?LinkId=619787')]
+param(
+ [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Name},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${RequiredVersion},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNull()]
+ [string]
+ ${MaximumVersion},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [uri]
+ ${Proxy},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${ProxyCredential},
+
+ [Parameter(ValueFromPipelineByPropertyName=$true)]
+ [pscredential]
+ [System.Management.Automation.CredentialAttribute()]
+ ${Credential},
+
+ [switch]
+ ${Force},
+
+ [switch]
+ ${AllowPrerelease},
+
+ [switch]
+ ${AcceptLicense},
+
+ [switch]
+ ${PassThru})
+
+ begin
+ {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
+ {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+
+ # PARAMETER MAP
+ # Parameter translations
+ $verArgs = @{}
+ if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
+ if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
+ $ver = Convert-VersionParamaters @verArgs
+ if ( $ver ) {
+ $PSBoundParameters['Version'] = $ver
+ }
+ # Parameter translations
+ if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
+ # Parameter Deletions (unsupported in v3)
+ if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
+ if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
+ # END PARAMETER MAP
+
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Update-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters }
+
+ # Set internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $true)
+ } catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ throw
+ }
+ }
+
+ process
+ {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ throw
+ }
+ }
+
+ end
+ {
+ try {
+ # Reset internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $false)
+ }
+ catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline.End()
+ } catch {
+ throw
+ }
+ }
+ <#
+ .ForwardHelpTargetName Update-Script
+ .ForwardHelpCategory Function
+ #>
+}
+
+function Update-ModuleManifest {
+[CmdletBinding(PositionalBinding = $false, DefaultParameterSetName = 'PathParameterSet', SupportsShouldProcess = $true, HelpUri = 'https://go.microsoft.com/fwlink/?LinkId=619793')]
+param(
+ [Parameter(ParameterSetName = 'PathParameterSet', Position=0, Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${Path},
+
+ [Parameter(ParameterSetName = 'LiteralPathParameterSet', Position=0, Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
+ [Alias('PSPath')]
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${LiteralPath},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${Version},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${Author},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${Description},
+
+ [ValidateNotNullOrEmpty()]
+ [Guid]
+ ${Guid},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${CompanyName},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${Copyright},
+
+ [ValidateNotNullOrEmpty()]
+ [Object[]]
+ ${RequiredModules},
+
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${ExternalModuleDependencies},
+
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${RequiredScripts},
+
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${ExternalScriptDependencies},
+
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Tags},
+
+ [ValidateNotNullOrEmpty()]
+ [Uri]
+ ${ProjectUri},
+
+ [ValidateNotNullOrEmpty()]
+ [Uri]
+ ${LicenseUri},
+
+ [ValidateNotNullOrEmpty()]
+ [Uri]
+ ${IconUri},
+
+ [string[]]
+ ${ReleaseNotes},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${PrivateData},
+
+ [switch]
+ ${PassThru},
+
+ [switch]
+ ${Force})
+
+ begin
+ {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
+ {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+
+ # PARAMETER MAP
+ # No parameter translations
+ # END PARAMETER MAP
+
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Update-PSModuleManifest', [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters }
+
+ # Set internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $true)
+ } catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ throw
+ }
+ }
+
+ process
+ {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ throw
+ }
+ }
+
+ end
+ {
+ try {
+ # Reset internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $false)
+ }
+ catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline.End()
+ } catch {
+ throw
+ }
+ }
+ <#
+ .ForwardHelpTargetName Update-ModuleManifest
+ .ForwardHelpCategory Function
+ #>
+}
+
+function Update-ScriptFileInfo {
+[CmdletBinding(PositionalBinding = $false, DefaultParameterSetName = 'PathParameterSet', SupportsShouldProcess = $true, HelpUri = 'https://go.microsoft.com/fwlink/?LinkId=619793')]
+param(
+ [Parameter(ParameterSetName = 'PathParameterSet', Position=0, Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${Path},
+
+ [Parameter(ParameterSetName = 'LiteralPathParameterSet', Position=0, Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
+ [Alias('PSPath')]
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${LiteralPath},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${Version},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${Author},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${Description},
+
+ [ValidateNotNullOrEmpty()]
+ [Guid]
+ ${Guid},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${CompanyName},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${Copyright},
+
+ [ValidateNotNullOrEmpty()]
+ [Object[]]
+ ${RequiredModules},
+
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${ExternalModuleDependencies},
+
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${RequiredScripts},
+
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${ExternalScriptDependencies},
+
+ [ValidateNotNullOrEmpty()]
+ [string[]]
+ ${Tags},
+
+ [ValidateNotNullOrEmpty()]
+ [Uri]
+ ${ProjectUri},
+
+ [ValidateNotNullOrEmpty()]
+ [Uri]
+ ${LicenseUri},
+
+ [ValidateNotNullOrEmpty()]
+ [Uri]
+ ${IconUri},
+
+ [string[]]
+ ${ReleaseNotes},
+
+ [ValidateNotNullOrEmpty()]
+ [string]
+ ${PrivateData},
+
+ [switch]
+ ${PassThru},
+
+ [switch]
+ ${Force})
+
+ begin
+ {
+ try {
+ $outBuffer = $null
+ if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
+ {
+ $PSBoundParameters['OutBuffer'] = 1
+ }
+
+ # PARAMETER MAP
+ # Parameter translations
+ if ( $PSBoundParameters['LiteralPath'] ) { $null = $PSBoundParameters.Remove('LiteralPath'); $PSBoundParameters['Path'] = $LiteralPath }
+ # Translate from string[] to string
+ if ( $PSBoundParameters['ReleaseNotes'] ) {
+ $PSBoundParameters['ReleaseNotes'] = $PSBoundParameters['ReleaseNotes'] -join "; "
+ }
+ # Parameter Deletions (unsupported in v3)
+ if ( $PSBoundParameters['PassThru'] ) { $null = $PSBoundParameters.Remove('PassThru') }
+ if ( $PSBoundParameters['Force'] ) { $null = $PSBoundParameters.Remove('Force') }
+ if ( $PSBoundParameters['WhatIf'] ) { $null = $PSBoundParameters.Remove('WhatIf') }
+ if ( $PSBoundParameters['Confirm'] ) { $null = $PSBoundParameters.Remove('Confirm') }
+ # END PARAMETER MAP
+
+ $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Update-PSScriptFileInfo', [System.Management.Automation.CommandTypes]::Cmdlet)
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters }
+
+ # Set internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $true)
+ } catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline = $scriptCmd.GetSteppablePipeline()
+ $steppablePipeline.Begin($PSCmdlet)
+ } catch {
+ throw
+ }
+ }
+
+ process
+ {
+ try {
+ $steppablePipeline.Process($_)
+ } catch {
+ throw
+ }
+ }
+
+ end
+ {
+ try {
+ # Reset internal hook for being invoked from Compat module
+ try {
+ [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("InvokedFromCompat", $false)
+ }
+ catch {
+ # Ignore if not available
+ }
+
+ $steppablePipeline.End()
+ } catch {
+ throw
+ }
+ }
+ <#
+ .ForwardHelpTargetName Update-ScriptFileInfo
+ .ForwardHelpCategory Function
+ #>
+}
+
+New-Alias -Name fimo -Value Find-Module
+New-Alias -Name inmo -Value Install-Module
+New-Alias -Name pumo -Value Publish-Module
+New-Alias -Name upmo -Value Update-Module
+
+$functionsToExport = @(
+ "Find-Command",
+ "Find-DscResource",
+ "Find-Module",
+ "Find-RoleCapability",
+ "Find-Script",
+ "Get-InstalledModule",
+ "Get-InstalledScript",
+ "Get-PSRepository",
+ "Install-Module",
+ "Install-Script",
+ "New-ScriptFileInfo",
+ "Publish-Module",
+ "Publish-Script",
+ "Register-PSRepository",
+ "Save-Module",
+ "Save-Script",
+ "Set-PSRepository",
+ "Test-ScriptFileInfo",
+ "Uninstall-Module",
+ "Uninstall-Script",
+ "Unregister-PSRepository",
+ "Update-Module",
+ "Update-Script",
+ "Update-ScriptFileInfo"
+)
+
+$aliasesToExport = @('
+ fimo',
+ 'inmo',
+ 'pumo',
+ 'upmo'
+)
+
+export-ModuleMember -Function $functionsToExport -Alias $aliasesToExport
diff --git a/src/PowerShellGetCompat.psm1 b/src/PowerShellGetCompat.psm1
deleted file mode 100644
index cf6a699..0000000
--- a/src/PowerShellGetCompat.psm1
+++ /dev/null
@@ -1,2638 +0,0 @@
-# PROXY HELPER
-# used to determine if we have a semantic version
-$semVerRegex = '^(?0|[1-9]\d*)\.(?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:-(?(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'
-
-# try to convert the string into a version (semantic or system)
-function Get-VersionType
-{
- param ( $versionString )
-
- # if this can be converted into a version, simple return it
- $version = $versionString -as [version]
- if ( $version ) {
- return $version
- }
-
- # if the string matches a semantic version, return it, but also return a lossy conversion to system.version
- if ( $versionString -match $semVerRegex ) {
- return [pscustomobject]@{
- Major = [int]$Matches['major']
- Minor = [int]$Matches['Minor']
- Patch = [int]$Matches['patch']
- PreReleaseLabel = [string]$matches['prerelease']
- BuildLabel = [string]$matches['buildmetadata']
- originalString = $versionString
- Version = [version]("{0}.{1}.{2}" -f $Matches['major'],$Matches['minor'],$Matches['patch'])
- }
- }
- return $null
-}
-
-# this handles comparison of version with semantic versions
-# this is all needed as semantic version exists only in core
-function Compare-Version
-{
- param ([string]$minimum, [string]$maximum)
-
- # this is done so we can use version to do our comparison
- $reference = Get-VersionType $minimum
- if ( ! $reference ) {
- throw "Cannot convert '$minimum' to version type"
- }
- $difference= Get-VersionType $maximum
- if ( ! $difference ) {
- throw "Cannot convert '$maximum' to version type"
- }
-
- if ( $reference -is [version] -and $difference -is [version] ) {
- if ( $reference -gt $difference ) {
- return 1
- }
- elseif ( $reference -lt $difference ) {
- return -1
- }
- }
- elseif ( $reference.version -is [version] -and $difference.version -is [version] ) {
- # two semantic versions
- if ( $reference.version -gt $difference.version ) {
- return 1
- }
- elseif ( $reference.version -lt $difference.version ) {
- return -1
- }
- }
- elseif ( $reference -is [version] -and $difference.version -is [version] ) {
- # one semantic version
- if ( $reference -gt $difference.version ) {
- return 1
- }
- elseif ( $reference -lt $difference.version ) {
- return -1
- }
- elseif ( $reference -eq $difference.version ) {
- # 1.0.0 is greater than 1.0.0-preview
- return 1
- }
- }
- elseif ( $reference.version -is [version] -and $difference -is [version] ) {
- # one semantic version
- if ( $reference.version -gt $difference ) {
- return 1
- }
- elseif ( $reference.version -lt $difference ) {
- return -1
- }
- elseif ( $reference.version -eq $difference ) {
- # 1.0.0 is greater than 1.0.0-preview
- return -1
- }
- }
- # Fall through
-
- if ( $reference.PreReleaseLabel -gt $difference.PreReleaseLabel ) {
- return 1
- }
- if ( $reference.PreReleaseLabel -lt $difference.PreReleaseLabel ) {
- return -1
- }
- # Fall through
-
- if ( $reference.BuildLabel -gt $difference.BuildLabel ) {
- return 1
- }
- if ( $reference.BuildLabel -lt $difference.BuildLabel ) {
- return -1
- }
-
- # Fall through, they are equivalent
- return 0
-}
-
-
-# Convert-VersionsToNugetVersion -RequiredVersion $RequiredVersion -MinimumVersion $MinimumVersion -MaximumVersion $MaximumVersion
-# this tries to figure out whether we have an improper use of version parameters
-# such as RequiredVersion with MinimumVersion or MaximumVersion
-function Convert-VersionsToNugetVersion
-{
- param ( $RequiredVersion, $MinimumVersion, $MaximumVersion )
- # validate that required is not used with minimum or maximum version
- if ( $RequiredVersion -and ($MinimumVersion -or $MaximumVersion) ) {
- throw "RequiredVersion may not be used with MinimumVersion or MaximumVersion"
- }
- elseif ( ! $RequiredVersion -and ! $MinimuVersion -and ! $MaximumVersion ) {
- return $null
- }
- if ( $RequiredVersion -eq '*' ) { return $RequiredVersion }
-
- # validate that we can actually convert the received version to an allowed either a system.version or semanticversion
- foreach ( $version in "RequiredVersion","MinimumVersion", "MaximumVersion" ) {
- if ( $PSBoundParameters[$version] ) {
- $v = $PSBoundParameters[$version] -as [System.Version]
- $sv = $PSBoundParameters[$version] -match $semVerRegex
- if ( ! ($v -or $sv) ) {
- $val = $PSBoundParameters[$version]
- throw "'$version' ($val) cannot be converted to System.Version or System.Management.Automation.SemanticVersion"
- }
- }
- }
-
- # we've made sure that we've validated the string we got is correct, so just pass it back
- # we've also made sure that we didn't mix min/max with required
- if ( $RequiredVersion ) {
- return "$RequiredVersion"
- }
-
- # now return the appropriate string
- if ( $MinimumVersion -and ! $MaximumVersion ) {
- if ( Get-VersionType $MinimumVersion ) {
- return "$MinimumVersion"
- }
- }
- elseif ( ! $MinimumVersion -and $MaximumVersion ) {
- # no minimum version
- if ( Get-VersionType $MaximumVersion ) {
- return "(,${MaximumVersion}]"
- }
- }
- else {
- $result = Compare-Version $MinimumVersion $MaximumVersion
- if ( $result -ge 0 ) {
- throw "'$MaximumVersion' must be greater than '$MinimumVersion'"
- }
- return "[${MinimumVersion},${MaximumVersion}]"
-
- }
-}
-
-# we attempt to convert the location to a uri
-# that way the user can do Register-PSRepository /tmp
-function Convert-ToUri ( [string]$location ) {
- $locationAsUri = $location -as [System.Uri]
- if ( $locationAsUri.Scheme ) {
- return $locationAsUri
- }
- # now determine if the path exists and is a directory
- # if it exists, return it as a file uri
- if ( Test-Path -PathType Container -LiteralPath $location ) {
- $locationAsUri = "file://${location}" -as [System.Uri]
- if( $locationAsUri.Scheme ) {
- return $locationAsUri
- }
- }
- throw "Cannot convert '$location' to System.Uri"
-}
-
-
-####
-####
-# Proxy functions
-# This is where we map the parameters from v2 to v3
-# In some cases we have the same parameters
-# In some cases we have parameters which are not used in v3 - these we will silently ignore
-# the goal in ignoring them is to provide ways for automation to succeed without error rather than provide exact
-# semantic behavior between v2 and v3
-# In some cases we have a way to map a v2 parameter into a v3 parameter
-# In those cases, we need to remove the parameter from the bound parameters and apply the value to the newly mapped parameter
-# In some cases we have a completely new parameter which we need to set.
-####
-####
-function Find-CommandProxy {
-[Alias('Find-Command')]
-[CmdletBinding(HelpUri='https://go.microsoft.com/fwlink/?LinkId=733636')]
-param(
- [Parameter(Position=0)]
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Name},
-
- [ValidateNotNullOrEmpty()]
- [string]
- ${ModuleName},
-
- [ValidateNotNull()]
- [string]
- ${MinimumVersion},
-
- [ValidateNotNull()]
- [string]
- ${MaximumVersion},
-
- [ValidateNotNull()]
- [string]
- ${RequiredVersion},
-
- [switch]
- ${AllVersions},
-
- [switch]
- ${AllowPrerelease},
-
- [ValidateNotNull()]
- [string[]]
- ${Tag},
-
- [ValidateNotNull()]
- [string]
- ${Filter},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [uri]
- ${Proxy},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${ProxyCredential},
-
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Repository})
-
-begin
-{
- Write-Warning -Message "The cmdlet 'Find-Command' is deprecated, please use 'Find-PSResource'."
- try {
- $outBuffer = $null
- if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
- {
- $PSBoundParameters['OutBuffer'] = 1
- }
-
- # PARAMETER MAP
- # add new specifier
- $PSBoundParameters['Type'] = 'command'
- # Parameter translations
- $verArgs = @{}
- if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion'); $verArgs['MinimumVersion'] = $MinumumVersion }
- if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
- if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
- if ( $PSBoundParameters['AllVersions'] ) { $null = $PSBoundParameters.Remove('AllVersions'); $verArgs['RequiredVersion'] = '*' }
- $ver = Convert-VersionsToNugetVersion @verArgs
- if ( $ver ) {
- $PSBoundParameters['Version'] = $ver
- }
- if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
- if ( $PSBoundParameters['Tag'] ) { $null = $PSBoundParameters.Remove('Tag'); $PSBoundParameters['Tags'] = $Tag }
- if ( $PSBoundParameters['DscResource'] ) { $null = $PSBoundParameters.Remove('DscResource'); $PSBoundParameters['Type'] = "DscResource" }
- if ( $PSBoundParameters['RoleCapability'] ) { $null = $PSBoundParameters.Remove('RoleCapability') ; $PSBoundParameters['Type'] = "RoleCapability"}
- if ( $PSBoundParameters['Command'] ) { $null = $PSBoundParameters.Remove('Command') ; $PSBoundParameters['Type'] = "command" }
- # Parameter Deletions (unsupported in v3)
- if ( $PSBoundParameters['Includes'] ) { $null = $PSBoundParameters.Remove('Includes') }
- if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
- if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
- # END PARAMETER MAP
-
- $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Find-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
- $scriptCmd = {& $wrappedCmd @PSBoundParameters }
-
- $steppablePipeline = $scriptCmd.GetSteppablePipeline()
- $steppablePipeline.Begin($PSCmdlet)
- } catch {
- throw
- }
-}
-
-process
-{
- try {
- $steppablePipeline.Process($_)
- } catch {
- throw
- }
-}
-
-end
-{
- try {
- $steppablePipeline.End()
- } catch {
- throw
- }
-}
-<#
-
-.ForwardHelpTargetName Find-Command
-.ForwardHelpCategory Function
-
-#>
-
-}
-
-
-function Find-DscResourceProxy {
-[Alias('Find-DscResource')]
-[CmdletBinding(HelpUri='https://go.microsoft.com/fwlink/?LinkId=517196')]
-param(
- [Parameter(Position=0)]
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Name},
-
- [ValidateNotNullOrEmpty()]
- [string]
- ${ModuleName},
-
- [ValidateNotNull()]
- [string]
- ${MinimumVersion},
-
- [ValidateNotNull()]
- [string]
- ${MaximumVersion},
-
- [ValidateNotNull()]
- [string]
- ${RequiredVersion},
-
- [switch]
- ${AllVersions},
-
- [switch]
- ${AllowPrerelease},
-
- [ValidateNotNull()]
- [string[]]
- ${Tag},
-
- [ValidateNotNull()]
- [string]
- ${Filter},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [uri]
- ${Proxy},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${ProxyCredential},
-
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Repository})
-
-begin
-{
- Write-Warning -Message "The cmdlet 'Find-DscResource' is deprecated, please use 'Find-PSResource'."
- try {
- $outBuffer = $null
- if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
- {
- $PSBoundParameters['OutBuffer'] = 1
- }
-
- # PARAMETER MAP
- # add new specifier
- $PSBoundParameters['Type'] = 'DscResource'
- # Parameter translations
- $verArgs = @{}
- if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion'); $verArgs['MinimumVersion'] = $MinumumVersion }
- if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
- if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
- if ( $PSBoundParameters['AllVersions'] ) { $null = $PSBoundParameters.Remove('AllVersions'); $verArgs['RequiredVersion'] = '*' }
- $ver = Convert-VersionsToNugetVersion @verArgs
- if ( $ver ) {
- $PSBoundParameters['Version'] = $ver
- }
-
- # Parameter Deletions (unsupported in v3)
- if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
- if ( $PSBoundParameters['Tag'] ) { $null = $PSBoundParameters.Remove('Tag'); $PSBoundParameters['Tags'] = $Tag }
- if ( $PSBoundParameters['Filter'] ) { $null = $PSBoundParameters.Remove('Filter') }
- if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
- if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
- # END PARAMETER MAP
-
- $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Find-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
- $scriptCmd = {& $wrappedCmd @PSBoundParameters }
-
- $steppablePipeline = $scriptCmd.GetSteppablePipeline()
- $steppablePipeline.Begin($PSCmdlet)
- } catch {
- throw
- }
-}
-
-process
-{
- try {
- $steppablePipeline.Process($_)
- } catch {
- throw
- }
-}
-
-end
-{
- try {
- $steppablePipeline.End()
- } catch {
- throw
- }
-}
-<#
-
-.ForwardHelpTargetName Find-DscResource
-.ForwardHelpCategory Function
-
-#>
-
-}
-
-function Find-ModuleProxy {
-[Alias('Find-Module')]
-[CmdletBinding(HelpUri='https://go.microsoft.com/fwlink/?LinkID=398574')]
-param(
- [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Name},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${MinimumVersion},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${MaximumVersion},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${RequiredVersion},
-
- [switch]
- ${AllVersions},
-
- [switch]
- ${IncludeDependencies},
-
- [ValidateNotNull()]
- [string]
- ${Filter},
-
- [ValidateNotNull()]
- [string[]]
- ${Tag},
-
- [ValidateSet('DscResource','Cmdlet','Function','RoleCapability')]
- [ValidateNotNull()]
- [string[]]
- ${Includes},
-
- [ValidateNotNull()]
- [string[]]
- ${DscResource},
-
- [ValidateNotNull()]
- [string[]]
- ${RoleCapability},
-
- [ValidateNotNull()]
- [string[]]
- ${Command},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [uri]
- ${Proxy},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${ProxyCredential},
-
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Repository},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${Credential},
-
- [switch]
- ${AllowPrerelease})
-
-begin
-{
- Write-Warning -Message "The cmdlet 'Find-Module' is deprecated, please use 'Find-PSResource'."
- try {
- $outBuffer = $null
- if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
- {
- $PSBoundParameters['OutBuffer'] = 1
- }
-
- # PARAMETER MAP
- # add new specifier
- $PSBoundParameters['Type'] = 'module'
- # Parameter translations
- $verArgs = @{}
- if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion'); $verArgs['MinimumVersion'] = $MinumumVersion }
- if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
- if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
- if ( $PSBoundParameters['AllVersions'] ) { $null = $PSBoundParameters.Remove('AllVersions'); $verArgs['RequiredVersion'] = '*' }
- $ver = Convert-VersionsToNugetVersion @verArgs
- if ( $ver ) {
- $PSBoundParameters['Version'] = $ver
- }
- if ( $PSBoundParameters['Tag'] ) { $null = $PSBoundParameters.Remove('Tag'); $PSBoundParameters['Tags'] = $Tag }
- if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
- if ( $PSBoundParameters['DscResource'] ) { $null = $PSBoundParameters.Remove('DscResource'); $PSBoundParameters['Type'] = "DscResource" }
- if ( $PSBoundParameters['RoleCapability'] ) { $null = $PSBoundParameters.Remove('RoleCapability'); $PSBoundParameters['Type'] = "RoleCapability" }
- if ( $PSBoundParameters['Command'] ) { $null = $PSBoundParameters.Remove('Command'); $PSBoundParameters['Type'] = "command" }
- # Parameter Deletions (unsupported in v3)
- if ( $PSBoundParameters['Includes'] ) { $null = $PSBoundParameters.Remove('Includes') }
- if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
- if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
- # END PARAMETER MAP
-
- $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Find-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
- $scriptCmd = {& $wrappedCmd @PSBoundParameters }
-
- $steppablePipeline = $scriptCmd.GetSteppablePipeline()
- $steppablePipeline.Begin($PSCmdlet)
- } catch {
- throw
- }
-}
-
-process
-{
- try {
- $steppablePipeline.Process($_)
- } catch {
- throw
- }
-}
-
-end
-{
- try {
- $steppablePipeline.End()
- } catch {
- throw
- }
-}
-<#
-
-.ForwardHelpTargetName Find-Module
-.ForwardHelpCategory Function
-
-#>
-
-}
-
-function Find-RoleCapabilityProxy {
-[Alias('Find-RoleCapability')]
-[CmdletBinding(HelpUri='https://go.microsoft.com/fwlink/?LinkId=718029')]
-param(
- [Parameter(Position=0)]
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Name},
-
- [ValidateNotNullOrEmpty()]
- [string]
- ${ModuleName},
-
- [ValidateNotNull()]
- [string]
- ${MinimumVersion},
-
- [ValidateNotNull()]
- [string]
- ${MaximumVersion},
-
- [ValidateNotNull()]
- [string]
- ${RequiredVersion},
-
- [switch]
- ${AllVersions},
-
- [switch]
- ${AllowPrerelease},
-
- [ValidateNotNull()]
- [string[]]
- ${Tag},
-
- [ValidateNotNull()]
- [string]
- ${Filter},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [uri]
- ${Proxy},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${ProxyCredential},
-
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Repository})
-
-begin
-{
- try {
- $outBuffer = $null
- if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
- {
- $PSBoundParameters['OutBuffer'] = 1
- }
-
- # PARAMETER MAP
- # add new specifier
- $PSBoundParameters['Type'] = 'RoleCapability'
- # Parameter translations
- $verArgs = @{}
- if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion'); $verArgs['MinimumVersion'] = $MinumumVersion }
- if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
- if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
- if ( $PSBoundParameters['AllVersions'] ) { $null = $PSBoundParameters.Remove('AllVersions'); $verArgs['RequiredVersion'] = '*' }
- $ver = Convert-VersionsToNugetVersion @verArgs
- if ( $ver ) {
- $PSBoundParameters['Version'] = $ver
- }
- if ( $PSBoundParameters['Tag'] ) { $null = $PSBoundParameters.Remove('Tag'); $PSBoundParameters['Tags'] = $Tag }
- if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
- # Parameter Deletions (unsupported in v3)
- if ( $PSBoundParameters['Filter'] ) { $null = $PSBoundParameters.Remove('Filter') }
- if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
- if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
- # END PARAMETER MAP
-
- $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Find-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
- $scriptCmd = {& $wrappedCmd @PSBoundParameters }
-
- $steppablePipeline = $scriptCmd.GetSteppablePipeline()
- $steppablePipeline.Begin($PSCmdlet)
- } catch {
- throw
- }
-}
-
-process
-{
- try {
- $steppablePipeline.Process($_)
- } catch {
- throw
- }
-}
-
-end
-{
- try {
- $steppablePipeline.End()
- } catch {
- throw
- }
-}
-<#
-
-.ForwardHelpTargetName Find-RoleCapability
-.ForwardHelpCategory Function
-
-#>
-
-}
-
-function Find-ScriptProxy {
-[Alias('Find-Script')]
-[CmdletBinding(HelpUri='https://go.microsoft.com/fwlink/?LinkId=619785')]
-param(
- [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Name},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${MinimumVersion},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${MaximumVersion},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${RequiredVersion},
-
- [switch]
- ${AllVersions},
-
- [switch]
- ${IncludeDependencies},
-
- [ValidateNotNull()]
- [string]
- ${Filter},
-
- [ValidateNotNull()]
- [string[]]
- ${Tag},
-
- [ValidateSet('Function','Workflow')]
- [ValidateNotNull()]
- [string[]]
- ${Includes},
-
- [ValidateNotNull()]
- [string[]]
- ${Command},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [uri]
- ${Proxy},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${ProxyCredential},
-
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Repository},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${Credential},
-
- [switch]
- ${AllowPrerelease})
-
-begin
-{
- Write-Warning -Message "The cmdlet 'Find-Script' is deprecated, please use 'Find-PSResource'."
- try {
- $outBuffer = $null
- if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
- {
- $PSBoundParameters['OutBuffer'] = 1
- }
-
- # PARAMETER MAP
- # add new specifier
- $PSBoundParameters['Type'] = 'script'
- # Parameter translations
- $verArgs = @{}
- if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion'); $verArgs['MinimumVersion'] = $MinumumVersion }
- if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
- if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
- if ( $PSBoundParameters['AllVersions'] ) { $null = $PSBoundParameters.Remove('AllVersions'); $verArgs['RequiredVersion'] = '*' }
- $ver = Convert-VersionsToNugetVersion @verArgs
- if ( $ver ) {
- $PSBoundParameters['Version'] = $ver
- }
- if ( $PSBoundParameters['Tag'] ) { $null = $PSBoundParameters.Remove('Tag'); $PSBoundParameters['Tags'] = $Tag }
- if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
-
- # Parameter Deletions (unsupported in v3)
- if ( $PSBoundParameters['Filter'] ) { $null = $PSBoundParameters.Remove('Filter') }
- if ( $PSBoundParameters['Includes'] ) { $null = $PSBoundParameters.Remove('Includes') }
- if ( $PSBoundParameters['Command'] ) { $null = $PSBoundParameters.Remove('Command') }
- if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
- if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
- # END PARAMETER MAP
-
- $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Find-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
- $scriptCmd = {& $wrappedCmd @PSBoundParameters }
-
- $steppablePipeline = $scriptCmd.GetSteppablePipeline()
- $steppablePipeline.Begin($PSCmdlet)
- } catch {
- throw
- }
-}
-
-process
-{
- try {
- $steppablePipeline.Process($_)
- } catch {
- throw
- }
-}
-
-end
-{
- try {
- $steppablePipeline.End()
- } catch {
- throw
- }
-}
-<#
-
-.ForwardHelpTargetName Find-Script
-.ForwardHelpCategory Function
-
-#>
-
-}
-
-function Get-InstalledModuleProxy {
-[Alias('Get-InstalledModule')]
-[CmdletBinding(HelpUri='https://go.microsoft.com/fwlink/?LinkId=526863')]
-param(
- [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Name},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${MinimumVersion},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${RequiredVersion},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${MaximumVersion},
-
- [switch]
- ${AllVersions},
-
- [switch]
- ${AllowPrerelease})
-
-begin
-{
- Write-Warning -Message "The cmdlet 'Get-InstalledModule' is deprecated, please use 'Get-PSResource'."
- try {
- $outBuffer = $null
- if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
- {
- $PSBoundParameters['OutBuffer'] = 1
- }
-
- # PARAMETER MAP
- # Parameter Deletions (unsupported in v3)
- if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion') }
- if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion') }
- if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion') }
- if ( $PSBoundParameters['AllVersions'] ) { $null = $PSBoundParameters.Remove('AllVersions') }
- if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease') }
- # END PARAMETER MAP
-
- $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Get-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
- $scriptCmd = {& $wrappedCmd @PSBoundParameters }
-
- $steppablePipeline = $scriptCmd.GetSteppablePipeline()
- $steppablePipeline.Begin($PSCmdlet)
- } catch {
- throw
- }
-}
-
-process
-{
- try {
- $steppablePipeline.Process($_)
- } catch {
- throw
- }
-}
-
-end
-{
- try {
- $steppablePipeline.End()
- } catch {
- throw
- }
-}
-<#
-
-.ForwardHelpTargetName Get-InstalledModule
-.ForwardHelpCategory Function
-
-#>
-
-}
-
-function Get-InstalledScriptProxy {
-[Alias('Get-InstalledScript')]
-[CmdletBinding(HelpUri='https://go.microsoft.com/fwlink/?LinkId=619790')]
-param(
- [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Name},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${MinimumVersion},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${RequiredVersion},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${MaximumVersion},
-
- [switch]
- ${AllowPrerelease})
-
-begin
-{
- Write-Warning -Message "The cmdlet 'Get-InstalledScript' is deprecated, please use 'Get-PSResource'."
- try {
- $outBuffer = $null
- if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
- {
- $PSBoundParameters['OutBuffer'] = 1
- }
-
- # PARAMETER MAP
- # add new specifier
- # Parameter translations
- # Parameter Deletions (unsupported in v3)
- if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion') }
- if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion') }
- if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion') }
- if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease') }
- # END PARAMETER MAP
-
- $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Get-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
- $scriptCmd = {& $wrappedCmd @PSBoundParameters }
-
- $steppablePipeline = $scriptCmd.GetSteppablePipeline()
- $steppablePipeline.Begin($PSCmdlet)
- } catch {
- throw
- }
-}
-
-process
-{
- try {
- $steppablePipeline.Process($_)
- } catch {
- throw
- }
-}
-
-end
-{
- try {
- $steppablePipeline.End()
- } catch {
- throw
- }
-}
-<#
-
-.ForwardHelpTargetName Get-InstalledScript
-.ForwardHelpCategory Function
-
-#>
-
-}
-
-function Get-PSRepositoryProxy {
-[Alias('Get-PSRepository')]
-[CmdletBinding(HelpUri='https://go.microsoft.com/fwlink/?LinkID=517127')]
-param(
- [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Name})
-
-begin
-{
- Write-Warning -Message "The cmdlet 'Get-PSRepository' is deprecated, please use 'Get-PSResourceRepository'."
- try {
- $outBuffer = $null
- if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
- {
- $PSBoundParameters['OutBuffer'] = 1
- }
-
- $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Get-PSResourceRepository', [System.Management.Automation.CommandTypes]::Cmdlet)
- $scriptCmd = {& $wrappedCmd @PSBoundParameters }
-
- $steppablePipeline = $scriptCmd.GetSteppablePipeline()
- $steppablePipeline.Begin($PSCmdlet)
- } catch {
- throw
- }
-}
-
-process
-{
- try {
- $steppablePipeline.Process($_)
- } catch {
- throw
- }
-}
-
-end
-{
- try {
- $steppablePipeline.End()
- } catch {
- throw
- }
-}
-<#
-
-.ForwardHelpTargetName Get-PSRepository
-.ForwardHelpCategory Function
-
-#>
-
-}
-
-function Install-ModuleProxy {
-[Alias('Install-Module')]
-[CmdletBinding(DefaultParameterSetName='NameParameterSet', SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='https://go.microsoft.com/fwlink/?LinkID=398573')]
-param(
- [Parameter(ParameterSetName='NameParameterSet', Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Name},
-
- [Parameter(ParameterSetName='InputObject', Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [psobject[]]
- ${InputObject},
-
- [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${MinimumVersion},
-
- [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${MaximumVersion},
-
- [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${RequiredVersion},
-
- [Parameter(ParameterSetName='NameParameterSet')]
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Repository},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${Credential},
-
- [ValidateSet('CurrentUser','AllUsers')]
- [string]
- ${Scope},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [uri]
- ${Proxy},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${ProxyCredential},
-
- [switch]
- ${AllowClobber},
-
- [switch]
- ${SkipPublisherCheck},
-
- [switch]
- ${Force},
-
- [Parameter(ParameterSetName='NameParameterSet')]
- [switch]
- ${AllowPrerelease},
-
- [switch]
- ${AcceptLicense},
-
- [switch]
- ${PassThru})
-
-begin
-{
- Write-Warning -Message "The cmdlet 'Install-Module' is deprecated, please use 'Install-PSResource'."
- try {
- $outBuffer = $null
- if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
- {
- $PSBoundParameters['OutBuffer'] = 1
- }
-
- # PARAMETER MAP
- # add new specifier
- # handle version changes
- $verArgs = @{}
- if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion'); $verArgs['MinimumVersion'] = $MinumumVersion }
- if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
- if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
- $ver = Convert-VersionsToNugetVersion @verArgs
- if ( $ver ) {
- $PSBoundParameters['Version'] = $ver
- }
-
- # Parameter translations
- if ( $PSBoundParameters['AllowClobber'] ) { $null = $PSBoundParameters.Remove('AllowClobber') }
- $PSBoundParameters['NoClobber'] = ! $AllowClobber
- if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
-
- # Parameter Deletions (unsupported in v3)
- if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
- if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
- if ( $PSBoundParameters['SkipPublisherCheck'] ) { $null = $PSBoundParameters.Remove('SkipPublisherCheck') }
- if ( $PSBoundParameters['InputObject'] ) { $null = $PSBoundParameters.Remove('InputObject') }
- if ( $PSBoundParameters['PassThru'] ) { $null = $PSBoundParameters.Remove('PassThru') }
- # END PARAMETER MAP
-
- $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Install-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
- $scriptCmd = {& $wrappedCmd @PSBoundParameters }
-
- $steppablePipeline = $scriptCmd.GetSteppablePipeline()
- $steppablePipeline.Begin($PSCmdlet)
- } catch {
- throw
- }
-}
-
-process
-{
- try {
- $steppablePipeline.Process($_)
- } catch {
- throw
- }
-}
-
-end
-{
- try {
- $steppablePipeline.End()
- } catch {
- throw
- }
-}
-<#
-
-.ForwardHelpTargetName Install-Module
-.ForwardHelpCategory Function
-
-#>
-
-}
-
-function Install-ScriptProxy {
-[Alias('Install-Script')]
-[CmdletBinding(DefaultParameterSetName='NameParameterSet', SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='https://go.microsoft.com/fwlink/?LinkId=619784')]
-param(
- [Parameter(ParameterSetName='NameParameterSet', Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Name},
-
- [Parameter(ParameterSetName='InputObject', Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [psobject[]]
- ${InputObject},
-
- [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${MinimumVersion},
-
- [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${MaximumVersion},
-
- [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${RequiredVersion},
-
- [Parameter(ParameterSetName='NameParameterSet')]
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Repository},
-
- [ValidateSet('CurrentUser','AllUsers')]
- [string]
- ${Scope},
-
- [switch]
- ${NoPathUpdate},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [uri]
- ${Proxy},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${ProxyCredential},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${Credential},
-
- [switch]
- ${Force},
-
- [Parameter(ParameterSetName='NameParameterSet')]
- [switch]
- ${AllowPrerelease},
-
- [switch]
- ${AcceptLicense},
-
- [switch]
- ${PassThru})
-
-begin
-{
- Write-Warning -Message "The cmdlet 'Install-Script' is deprecated, please use 'Install-PSResource'."
- try {
- $outBuffer = $null
- if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
- {
- $PSBoundParameters['OutBuffer'] = 1
- }
-
- # PARAMETER MAP
- # add new specifier
- # handle version changes
- $verArgs = @{}
- if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion'); $verArgs['MinimumVersion'] = $MinumumVersion }
- if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
- if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
- $ver = Convert-VersionsToNugetVersion @verArgs
- if ( $ver ) {
- $PSBoundParameters['Version'] = $ver
- }
- # Parameter translations
- if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
- # Parameter Deletions (unsupported in v3)
- if ( $PSBoundParameters['InputObject'] ) { $null = $PSBoundParameters.Remove('InputObject') }
- if ( $PSBoundParameters['NoPathUpdate'] ) { $null = $PSBoundParameters.Remove('NoPathUpdate') }
- if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
- if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
- if ( $PSBoundParameters['PassThru'] ) { $null = $PSBoundParameters.Remove('PassThru') }
- # END PARAMETER MAP
-
- $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Install-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
- $scriptCmd = {& $wrappedCmd @PSBoundParameters }
-
- $steppablePipeline = $scriptCmd.GetSteppablePipeline()
- $steppablePipeline.Begin($PSCmdlet)
- } catch {
- throw
- }
-}
-
-process
-{
- try {
- $steppablePipeline.Process($_)
- } catch {
- throw
- }
-}
-
-end
-{
- try {
- $steppablePipeline.End()
- } catch {
- throw
- }
-}
-<#
-
-.ForwardHelpTargetName Install-Script
-.ForwardHelpCategory Function
-
-#>
-
-}
-
-function Publish-ModuleProxy {
-[Alias('Publish-Module')]
-[CmdletBinding(DefaultParameterSetName='ModuleNameParameterSet', SupportsShouldProcess=$true, ConfirmImpact='Medium', PositionalBinding=$false, HelpUri='https://go.microsoft.com/fwlink/?LinkID=398575')]
-param(
- [Parameter(ParameterSetName='ModuleNameParameterSet', Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [string]
- ${Name},
-
- [Parameter(ParameterSetName='ModulePathParameterSet', Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [string]
- ${Path},
-
- [Parameter(ParameterSetName='ModuleNameParameterSet')]
- [ValidateNotNullOrEmpty()]
- [string]
- ${RequiredVersion},
-
- [ValidateNotNullOrEmpty()]
- [string]
- ${NuGetApiKey},
-
- [ValidateNotNullOrEmpty()]
- [string]
- ${Repository},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${Credential},
-
- [ValidateSet('2.0')]
- [version]
- ${FormatVersion},
-
- [string[]]
- ${ReleaseNotes},
-
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Tags},
-
- [ValidateNotNullOrEmpty()]
- [uri]
- ${LicenseUri},
-
- [ValidateNotNullOrEmpty()]
- [uri]
- ${IconUri},
-
- [ValidateNotNullOrEmpty()]
- [uri]
- ${ProjectUri},
-
- [Parameter(ParameterSetName='ModuleNameParameterSet')]
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Exclude},
-
- [switch]
- ${Force},
-
- [Parameter(ParameterSetName='ModuleNameParameterSet')]
- [switch]
- ${AllowPrerelease},
-
- [switch]
- ${SkipAutomaticTags})
-
-begin
-{
- Write-Warning -Message "The cmdlet 'Publish-Module' is deprecated, please use 'Publish-PSResource'."
- try {
- $outBuffer = $null
- if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
- {
- $PSBoundParameters['OutBuffer'] = 1
- }
-
- # PARAMETER MAP
- # Parameter translations
- if ( $PSBoundParameters['NuGetApiKey'] ) { $null = $PSBoundParameters.Remove('NuGetApiKey'); $PSBoundParameters['APIKey'] = $NuGetApiKey }
- # Parameter Deletions (unsupported in v3)
- if ( $PSBoundParameters['Name'] ) { $null = $PSBoundParameters.Remove('Name') }
- if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion') }
- if ( $PSBoundParameters['Repository'] ) { $null = $PSBoundParameters.Remove('Repository') }
- if ( $PSBoundParameters['FormatVersion'] ) { $null = $PSBoundParameters.Remove('FormatVersion') }
- if ( $PSBoundParameters['Force'] ) { $null = $PSBoundParameters.Remove('Force') }
- if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease') }
- if ( $PSBoundParameters['SkipAutomaticTags'] ) { $null = $PSBoundParameters.Remove('SkipAutomaticTags') }
- # END PARAMETER MAP
-
- $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Publish-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
- $scriptCmd = {& $wrappedCmd @PSBoundParameters }
-
- $steppablePipeline = $scriptCmd.GetSteppablePipeline()
- $steppablePipeline.Begin($PSCmdlet)
- } catch {
- throw
- }
-}
-
-process
-{
- try {
- $steppablePipeline.Process($_)
- } catch {
- throw
- }
-}
-
-end
-{
- try {
- $steppablePipeline.End()
- } catch {
- throw
- }
-}
-<#
-
-.ForwardHelpTargetName Publish-Module
-.ForwardHelpCategory Function
-
-#>
-
-}
-
-function Publish-ScriptProxy {
-[Alias('Publish-Script')]
-[CmdletBinding(DefaultParameterSetName='PathParameterSet', SupportsShouldProcess=$true, ConfirmImpact='Medium', PositionalBinding=$false, HelpUri='https://go.microsoft.com/fwlink/?LinkId=619788')]
-param(
- [Parameter(ParameterSetName='PathParameterSet', Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [string]
- ${Path},
-
- [Parameter(ParameterSetName='LiteralPathParameterSet', Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
- [Alias('PSPath')]
- [ValidateNotNullOrEmpty()]
- [string]
- ${LiteralPath},
-
- [ValidateNotNullOrEmpty()]
- [string]
- ${NuGetApiKey},
-
- [ValidateNotNullOrEmpty()]
- [string]
- ${Repository},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${Credential},
-
- [switch]
- ${Force})
-
-begin
-{
- Write-Warning -Message "The cmdlet 'Publish-Script' is deprecated, please use 'Publish-PSResource'."
- try {
- $outBuffer = $null
- if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
- {
- $PSBoundParameters['OutBuffer'] = 1
- }
-
- # PARAMETER MAP
- # add new specifier
- # Parameter translations
- if ( $PSBoundParameters['NuGetApiKey'] ) { $null = $PSBoundParameters.Remove('NuGetApiKey'); $PSBoundParameters['APIKey'] = $NuGetApiKey }
- # Parameter Deletions (unsupported in v3)
- if ( $PSBoundParameters['Force'] ) { $null = $PSBoundParameters.Remove('Force') }
- # END PARAMETER MAP
-
- $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Publish-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
- $scriptCmd = {& $wrappedCmd @PSBoundParameters }
-
- $steppablePipeline = $scriptCmd.GetSteppablePipeline()
- $steppablePipeline.Begin($PSCmdlet)
- } catch {
- throw
- }
-}
-
-process
-{
- try {
- $steppablePipeline.Process($_)
- } catch {
- throw
- }
-}
-
-end
-{
- try {
- $steppablePipeline.End()
- } catch {
- throw
- }
-}
-<#
-
-.ForwardHelpTargetName Publish-Script
-.ForwardHelpCategory Function
-
-#>
-
-}
-
-function Register-PSRepositoryProxy {
-[Alias('Register-PSRepository')]
-[CmdletBinding(DefaultParameterSetName='NameParameterSet', HelpUri='https://go.microsoft.com/fwlink/?LinkID=517129')]
-param(
- [Parameter(ParameterSetName='NameParameterSet', Mandatory=$true, Position=0)]
- [ValidateNotNullOrEmpty()]
- [string]
- ${Name},
-
- [Parameter(ParameterSetName='NameParameterSet', Mandatory=$true, Position=1)]
- [ValidateNotNullOrEmpty()]
- [uri]
- ${SourceLocation},
-
- [Parameter(ParameterSetName='NameParameterSet')]
- [ValidateNotNullOrEmpty()]
- [uri]
- ${PublishLocation},
-
- [Parameter(ParameterSetName='NameParameterSet')]
- [ValidateNotNullOrEmpty()]
- [uri]
- ${ScriptSourceLocation},
-
- [Parameter(ParameterSetName='NameParameterSet')]
- [ValidateNotNullOrEmpty()]
- [uri]
- ${ScriptPublishLocation},
-
- [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${Credential},
-
- [Parameter(ParameterSetName='PSGalleryParameterSet', Mandatory=$true)]
- [switch]
- ${Default},
-
- [ValidateSet('Trusted','Untrusted')]
- [string]
- ${InstallationPolicy},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [uri]
- ${Proxy},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${ProxyCredential},
-
- [Parameter(ParameterSetName='NameParameterSet')]
- [ValidateNotNullOrEmpty()]
- [string]
- ${PackageManagementProvider})
-
-begin
-{
- Write-Warning -Message "The cmdlet 'Register-PSRepository' is deprecated, please use 'Register-PSResourceRepository'."
- try {
- $outBuffer = $null
- if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
- {
- $PSBoundParameters['OutBuffer'] = 1
- }
-
- # PARAMETER MAP
- # Parameter translations
- if ( $PSBoundParameters['InstallationPolicy'] ) {
- $null = $PSBoundParameters.Remove('InstallationPolicy')
- if ( $InstallationPolicy -eq "Trusted" ) {
- $PSBoundParameters['Trusted'] = $true
- }
- }
- if ( $PSBoundParameters['SourceLocation'] ) { $null = $PSBoundParameters.Remove('SourceLocation'); $PSBoundParameters['Url'] = Convert-ToUri -location $SourceLocation }
- if ( $PSBoundParameters['Default'] ) { $null = $PSBoundParameters.Remove('Default'); $PSBoundParameters['PSGallery'] = $Default }
-
- # Parameter Deletions (unsupported in v3)
- if ( $PSBoundParameters['PublishLocation'] ) { $null = $PSBoundParameters.Remove('PublishLocation') }
- if ( $PSBoundParameters['ScriptSourceLocation'] ) { $null = $PSBoundParameters.Remove('ScriptSourceLocation') }
- if ( $PSBoundParameters['ScriptPublishLocation'] ) { $null = $PSBoundParameters.Remove('ScriptPublishLocation') }
- if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
- if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
- if ( $PSBoundParameters['PackageManagementProvider'] ) { $null = $PSBoundParameters.Remove('PackageManagementProvider') }
- # END PARAMETER MAP
-
- $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Register-PSResourceRepository', [System.Management.Automation.CommandTypes]::Cmdlet)
- $scriptCmd = {& $wrappedCmd @PSBoundParameters }
-
- $steppablePipeline = $scriptCmd.GetSteppablePipeline()
- $steppablePipeline.Begin($PSCmdlet)
- } catch {
- throw
- }
-}
-
-process
-{
- try {
- $steppablePipeline.Process($_)
- } catch {
- throw
- }
-}
-
-end
-{
- try {
- $steppablePipeline.End()
- } catch {
- throw
- }
-}
-<#
-
-.ForwardHelpTargetName Register-PSRepository
-.ForwardHelpCategory Function
-
-#>
-
-}
-
-function Save-ModuleProxy {
-[Alias('Save-Module')]
-[CmdletBinding(DefaultParameterSetName='NameAndPathParameterSet', SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='https://go.microsoft.com/fwlink/?LinkId=531351')]
-param(
- [Parameter(ParameterSetName='NameAndLiteralPathParameterSet', Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
- [Parameter(ParameterSetName='NameAndPathParameterSet', Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Name},
-
- [Parameter(ParameterSetName='InputObjectAndLiteralPathParameterSet', Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
- [Parameter(ParameterSetName='InputObjectAndPathParameterSet', Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [psobject[]]
- ${InputObject},
-
- [Parameter(ParameterSetName='NameAndLiteralPathParameterSet', ValueFromPipelineByPropertyName=$true)]
- [Parameter(ParameterSetName='NameAndPathParameterSet', ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${MinimumVersion},
-
- [Parameter(ParameterSetName='NameAndLiteralPathParameterSet', ValueFromPipelineByPropertyName=$true)]
- [Parameter(ParameterSetName='NameAndPathParameterSet', ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${MaximumVersion},
-
- [Parameter(ParameterSetName='NameAndLiteralPathParameterSet', ValueFromPipelineByPropertyName=$true)]
- [Parameter(ParameterSetName='NameAndPathParameterSet', ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${RequiredVersion},
-
- [Parameter(ParameterSetName='NameAndLiteralPathParameterSet', ValueFromPipelineByPropertyName=$true)]
- [Parameter(ParameterSetName='NameAndPathParameterSet', ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Repository},
-
- [Parameter(ParameterSetName='InputObjectAndPathParameterSet', Mandatory=$true, Position=1, ValueFromPipelineByPropertyName=$true)]
- [Parameter(ParameterSetName='NameAndPathParameterSet', Mandatory=$true, Position=1, ValueFromPipelineByPropertyName=$true)]
- [string]
- ${Path},
-
- [Parameter(ParameterSetName='InputObjectAndLiteralPathParameterSet', Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
- [Parameter(ParameterSetName='NameAndLiteralPathParameterSet', Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
- [Alias('PSPath')]
- [string]
- ${LiteralPath},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [uri]
- ${Proxy},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${ProxyCredential},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${Credential},
-
- [switch]
- ${Force},
-
- [Parameter(ParameterSetName='NameAndLiteralPathParameterSet')]
- [Parameter(ParameterSetName='NameAndPathParameterSet')]
- [switch]
- ${AllowPrerelease},
-
- [switch]
- ${AcceptLicense})
-
-begin
-{
- Write-Warning -Message "The cmdlet 'Save-Module' is deprecated, please use 'Save-PSResource'."
- try {
- $outBuffer = $null
- if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
- {
- $PSBoundParameters['OutBuffer'] = 1
- }
-
- # PARAMETER MAP
- # add new specifier
- # remove until available
- if ( $PSBoundParameters['InputObject'] ) { $null = $PSBoundParameters.Remove('InputObject') }
-
- # handle version changes
- $verArgs = @{}
- if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion'); $verArgs['MinimumVersion'] = $MaximumVersion }
- if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
- if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
- $ver = Convert-VersionsToNugetVersion @verArgs
- if ( $ver ) {
- $PSBoundParameters['Version'] = $ver
- }
-
- # Parameter translations
- if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
- if ( $PSBoundParameters['LiteralPath'] ) { $null = $PSBoundParameters.Remove('LiteralPath'); $PSBoundParameters['Path'] = $LiteralPath }
-
- # Parameter Deletions (unsupported in v3)
- if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
- if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
- if ( $PSBoundParameters['Force'] ) { $null = $PSBoundParameters.Remove('Force') }
- if ( $PSBoundParameters['AcceptLicense'] ) { $null = $PSBoundParameters.Remove('AcceptLicense') }
- # END PARAMETER MAP
-
- $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Save-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
- $scriptCmd = {& $wrappedCmd @PSBoundParameters }
-
- $steppablePipeline = $scriptCmd.GetSteppablePipeline()
- $steppablePipeline.Begin($PSCmdlet)
- } catch {
- throw
- }
-}
-
-process
-{
- try {
- $steppablePipeline.Process($_)
- } catch {
- throw
- }
-}
-
-end
-{
- try {
- $steppablePipeline.End()
- } catch {
- throw
- }
-}
-<#
-
-.ForwardHelpTargetName Save-Module
-.ForwardHelpCategory Function
-
-#>
-
-}
-
-function Save-ScriptProxy {
-[Alias('Save-Script')]
-[CmdletBinding(DefaultParameterSetName='NameAndPathParameterSet', SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='https://go.microsoft.com/fwlink/?LinkId=619786')]
-param(
- [Parameter(ParameterSetName='NameAndLiteralPathParameterSet', Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
- [Parameter(ParameterSetName='NameAndPathParameterSet', Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Name},
-
- [Parameter(ParameterSetName='InputObjectAndLiteralPathParameterSet', Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
- [Parameter(ParameterSetName='InputObjectAndPathParameterSet', Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [psobject[]]
- ${InputObject},
-
- [Parameter(ParameterSetName='NameAndLiteralPathParameterSet', ValueFromPipelineByPropertyName=$true)]
- [Parameter(ParameterSetName='NameAndPathParameterSet', ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${MinimumVersion},
-
- [Parameter(ParameterSetName='NameAndLiteralPathParameterSet', ValueFromPipelineByPropertyName=$true)]
- [Parameter(ParameterSetName='NameAndPathParameterSet', ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${MaximumVersion},
-
- [Parameter(ParameterSetName='NameAndLiteralPathParameterSet', ValueFromPipelineByPropertyName=$true)]
- [Parameter(ParameterSetName='NameAndPathParameterSet', ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${RequiredVersion},
-
- [Parameter(ParameterSetName='NameAndLiteralPathParameterSet', ValueFromPipelineByPropertyName=$true)]
- [Parameter(ParameterSetName='NameAndPathParameterSet', ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Repository},
-
- [Parameter(ParameterSetName='InputObjectAndPathParameterSet', Mandatory=$true, Position=1, ValueFromPipelineByPropertyName=$true)]
- [Parameter(ParameterSetName='NameAndPathParameterSet', Mandatory=$true, Position=1, ValueFromPipelineByPropertyName=$true)]
- [string]
- ${Path},
-
- [Parameter(ParameterSetName='InputObjectAndLiteralPathParameterSet', Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
- [Parameter(ParameterSetName='NameAndLiteralPathParameterSet', Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
- [Alias('PSPath')]
- [string]
- ${LiteralPath},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [uri]
- ${Proxy},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${ProxyCredential},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${Credential},
-
- [switch]
- ${Force},
-
- [Parameter(ParameterSetName='NameAndLiteralPathParameterSet')]
- [Parameter(ParameterSetName='NameAndPathParameterSet')]
- [switch]
- ${AllowPrerelease},
-
- [switch]
- ${AcceptLicense})
-
-begin
-{
- Write-Warning -Message "The cmdlet 'Save-Script' is deprecated, please use 'Save-PSResource'."
- try {
- $outBuffer = $null
- if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
- {
- $PSBoundParameters['OutBuffer'] = 1
- }
-
- # PARAMETER MAP
- # add new specifiers
-
- # handle version changes
- $verArgs = @{}
- if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion'); $verArgs['MinimumVersion'] = $MaximumVersion }
- if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
- if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
- $ver = Convert-VersionsToNugetVersion @verArgs
- if ( $ver ) {
- $PSBoundParameters['Version'] = $ver
- }
-
- # Parameter translations
- # LiteralPath needs to be converted to Path - we know they won't be used together because they're in different parameter sets
- if ( $PSBoundParameters['LiteralPath'] ) { $null = $PSBoundParameters.Remove('LiteralPath'); $PSBoundParameters['Path'] = $LiteralPath }
- if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
-
- # Parameter Deletions (unsupported in v3)
- if ( $PSBoundParameters['InputObject'] ) { $null = $PSBoundParameters.Remove('InputObject') }
- if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
- if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
- if ( $PSBoundParameters['Force'] ) { $null = $PSBoundParameters.Remove('Force') }
- # END PARAMETER MAP
-
- $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Save-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
- $scriptCmd = {& $wrappedCmd @PSBoundParameters }
-
- $steppablePipeline = $scriptCmd.GetSteppablePipeline()
- $steppablePipeline.Begin($PSCmdlet)
- } catch {
- throw
- }
-}
-
-process
-{
- try {
- $steppablePipeline.Process($_)
- } catch {
- throw
- }
-}
-
-end
-{
- try {
- $steppablePipeline.End()
- } catch {
- throw
- }
-}
-<#
-
-.ForwardHelpTargetName Save-Script
-.ForwardHelpCategory Function
-
-#>
-
-}
-
-function Set-PSRepositoryProxy {
-[Alias('Set-PSRepository')]
-[CmdletBinding(PositionalBinding=$false, HelpUri='https://go.microsoft.com/fwlink/?LinkID=517128')]
-param(
- [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [string]
- ${Name},
-
- [Parameter(Position=1)]
- [ValidateNotNullOrEmpty()]
- [uri]
- ${SourceLocation},
-
- [ValidateNotNullOrEmpty()]
- [uri]
- ${PublishLocation},
-
- [ValidateNotNullOrEmpty()]
- [uri]
- ${ScriptSourceLocation},
-
- [ValidateNotNullOrEmpty()]
- [uri]
- ${ScriptPublishLocation},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${Credential},
-
- [ValidateSet('Trusted','Untrusted')]
- [string]
- ${InstallationPolicy},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [uri]
- ${Proxy},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${ProxyCredential},
-
- [ValidateNotNullOrEmpty()]
- [string]
- ${PackageManagementProvider})
-
-begin
-{
- Write-Warning -Message "The cmdlet 'Set-PSRepository' is deprecated, please use 'Set-PSResourceRepository'."
- try {
- $outBuffer = $null
- if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
- {
- $PSBoundParameters['OutBuffer'] = 1
- }
-
- # PARAMETER MAP
- # add new specifier
- # Parameter translations
- if ( $PSBoundParameters['InstallationPolicy'] ) {
- $null = $PSBoundParameters.Remove('InstallationPolicy')
- if ( $InstallationPolicy -eq "Trusted" ) {
- $PSBoundParameters['Trusted'] = $true
- }
- else {
- $PSBoundParameters['Trusted'] = $false
- }
- }
- if ( $PSBoundParameters['SourceLocation'] ) { $null = $PSBoundParameters.Remove('SourceLocation'); $PSBoundParameters['Url'] = Convert-ToUri -location $SourceLocation }
- if ( $PSBoundParameters['Default'] ) { $null = $PSBoundParameters.Remove('Default'); $PSBoundParameters['PSGallery'] = $Default }
-
- # Parameter Deletions (unsupported in v3)
- if ( $PSBoundParameters['PublishLocation'] ) { $null = $PSBoundParameters.Remove('PublishLocation') }
- if ( $PSBoundParameters['ScriptSourceLocation'] ) { $null = $PSBoundParameters.Remove('ScriptSourceLocation') }
- if ( $PSBoundParameters['ScriptPublishLocation'] ) { $null = $PSBoundParameters.Remove('ScriptPublishLocation') }
- if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
- if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
- if ( $PSBoundParameters['PackageManagementProvider'] ) { $null = $PSBoundParameters.Remove('PackageManagementProvider') }
-
- # END PARAMETER MAP
-
- $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Set-PSResourceRepository', [System.Management.Automation.CommandTypes]::Cmdlet)
- $scriptCmd = {& $wrappedCmd @PSBoundParameters }
-
- $steppablePipeline = $scriptCmd.GetSteppablePipeline()
- $steppablePipeline.Begin($PSCmdlet)
- } catch {
- throw
- }
-}
-
-process
-{
- try {
- $steppablePipeline.Process($_)
- } catch {
- throw
- }
-}
-
-end
-{
- try {
- $steppablePipeline.End()
- } catch {
- throw
- }
-}
-<#
-
-.ForwardHelpTargetName Set-PSRepository
-.ForwardHelpCategory Function
-
-#>
-
-}
-
-function Uninstall-ModuleProxy {
-[Alias('Uninstall-Module')]
-[CmdletBinding(DefaultParameterSetName='NameParameterSet', SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='https://go.microsoft.com/fwlink/?LinkId=526864')]
-param(
- [Parameter(ParameterSetName='NameParameterSet', Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Name},
-
- [Parameter(ParameterSetName='InputObject', Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [psobject[]]
- ${InputObject},
-
- [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${MinimumVersion},
-
- [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${RequiredVersion},
-
- [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${MaximumVersion},
-
- [Parameter(ParameterSetName='NameParameterSet')]
- [switch]
- ${AllVersions},
-
- [switch]
- ${Force},
-
- [Parameter(ParameterSetName='NameParameterSet')]
- [switch]
- ${AllowPrerelease})
-
-begin
-{
- Write-Warning -Message "The cmdlet 'Uninstall-Module' is deprecated, please use 'Uninstall-PSResource'."
- try {
- $outBuffer = $null
- if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
- {
- $PSBoundParameters['OutBuffer'] = 1
- }
-
- # PARAMETER MAP
- # add new specifier
- # Parameter translations
- if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion'); $verArgs['MinimumVersion'] = $MinumumVersion }
- if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
- if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
- if ( $PSBoundParameters['AllVersions'] ) { $null = $PSBoundParameters.Remove('AllVersions'); $verArgs['RequiredVersion'] = '*' }
- $ver = Convert-VersionsToNugetVersion @verArgs
- if ( $ver ) {
- $PSBoundParameters['Version'] = $ver
- }
- # Parameter Deletions (unsupported in v3)
- if ( $PSBoundParameters['InputObject'] ) { $null = $PSBoundParameters.Remove('InputObject') }
- if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease') }
- # END PARAMETER MAP
-
- $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Uninstall-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
- $scriptCmd = {& $wrappedCmd @PSBoundParameters }
-
- $steppablePipeline = $scriptCmd.GetSteppablePipeline()
- $steppablePipeline.Begin($PSCmdlet)
- } catch {
- throw
- }
-}
-
-process
-{
- try {
- $steppablePipeline.Process($_)
- } catch {
- throw
- }
-}
-
-end
-{
- try {
- $steppablePipeline.End()
- } catch {
- throw
- }
-}
-<#
-
-.ForwardHelpTargetName Uninstall-Module
-.ForwardHelpCategory Function
-
-#>
-
-}
-
-function Uninstall-ScriptProxy {
-[Alias('Uninstall-Script')]
-[CmdletBinding(DefaultParameterSetName='NameParameterSet', SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='https://go.microsoft.com/fwlink/?LinkId=619789')]
-param(
- [Parameter(ParameterSetName='NameParameterSet', Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Name},
-
- [Parameter(ParameterSetName='InputObject', Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [psobject[]]
- ${InputObject},
-
- [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${MinimumVersion},
-
- [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${RequiredVersion},
-
- [Parameter(ParameterSetName='NameParameterSet', ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${MaximumVersion},
-
- [switch]
- ${Force},
-
- [Parameter(ParameterSetName='NameParameterSet')]
- [switch]
- ${AllowPrerelease})
-
-begin
-{
- Write-Warning -Message "The cmdlet 'Uninstall-Script' is deprecated, please use 'Uninstall-PSResource'."
- try {
- $outBuffer = $null
- if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
- {
- $PSBoundParameters['OutBuffer'] = 1
- }
-
- # PARAMETER MAP
- # Parameter translations
- if ( $PSBoundParameters['MinimumVersion'] ) { $null = $PSBoundParameters.Remove('MinimumVersion'); $verArgs['MinimumVersion'] = $MinumumVersion }
- if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
- if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
- if ( $PSBoundParameters['AllVersions'] ) { $null = $PSBoundParameters.Remove('AllVersions'); $verArgs['RequiredVersion'] = '*' }
- $ver = Convert-VersionsToNugetVersion @verArgs
- if ( $ver ) {
- $PSBoundParameters['Version'] = $ver
- }
- # Parameter Deletions (unsupported in v3)
- if ( $PSBoundParameters['InputObject'] ) { $null = $PSBoundParameters.Remove('InputObject') }
- if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease') }
- # END PARAMETER MAP
-
- $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Uninstall-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
- $scriptCmd = {& $wrappedCmd @PSBoundParameters }
-
- $steppablePipeline = $scriptCmd.GetSteppablePipeline()
- $steppablePipeline.Begin($PSCmdlet)
- } catch {
- throw
- }
-}
-
-process
-{
- try {
- $steppablePipeline.Process($_)
- } catch {
- throw
- }
-}
-
-end
-{
- try {
- $steppablePipeline.End()
- } catch {
- throw
- }
-}
-<#
-
-.ForwardHelpTargetName Uninstall-Script
-.ForwardHelpCategory Function
-
-#>
-
-}
-
-function Unregister-PSRepositoryProxy {
-[Alias('Unregister-PSRepository')]
-[CmdletBinding(HelpUri='https://go.microsoft.com/fwlink/?LinkID=517130')]
-param(
- [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Name})
-
-begin
-{
- Write-Warning -Message "The cmdlet 'Unregister-PSRepository' is deprecated, please use 'Unregister-PSResourceRepository'."
- try {
- $outBuffer = $null
- if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
- {
- $PSBoundParameters['OutBuffer'] = 1
- }
-
- # PARAMETER MAP
- # No changes between Unregister-PSRepository and Unregister-PSResourceRepository
- # END PARAMETER MAP
-
- $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Unregister-PSResourceRepository', [System.Management.Automation.CommandTypes]::Cmdlet)
- $scriptCmd = {& $wrappedCmd @PSBoundParameters }
-
- $steppablePipeline = $scriptCmd.GetSteppablePipeline()
- $steppablePipeline.Begin($PSCmdlet)
- } catch {
- throw
- }
-}
-
-process
-{
- try {
- $steppablePipeline.Process($_)
- } catch {
- throw
- }
-}
-
-end
-{
- try {
- $steppablePipeline.End()
- } catch {
- throw
- }
-}
-<#
-
-.ForwardHelpTargetName Unregister-PSRepository
-.ForwardHelpCategory Function
-
-#>
-
-}
-
-function Update-ModuleProxy {
-[Alias('Update-Module')]
-[CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='https://go.microsoft.com/fwlink/?LinkID=398576')]
-param(
- [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Name},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${RequiredVersion},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${MaximumVersion},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${Credential},
-
- [ValidateSet('CurrentUser','AllUsers')]
- [string]
- ${Scope},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [uri]
- ${Proxy},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${ProxyCredential},
-
- [switch]
- ${Force},
-
- [switch]
- ${AllowPrerelease},
-
- [switch]
- ${AcceptLicense},
-
- [switch]
- ${PassThru})
-
-begin
-{
- Write-Warning -Message "The cmdlet 'Update-Module' is deprecated, please use 'Update-PSResource'."
- try {
- $outBuffer = $null
- if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
- {
- $PSBoundParameters['OutBuffer'] = 1
- }
-
- # PARAMETER MAP
- $PSBoundParameters['Type'] = 'module'
- # handle version changes
- $verArgs = @{}
- if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
- if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
- $ver = Convert-VersionsToNugetVersion @verArgs
- if ( $ver ) {
- $PSBoundParameters['Version'] = $ver
- }
-
- # Parameter translations
- if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
-
- # Parameter Deletions (unsupported in v3)
- if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
- if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
- if ( $PSBoundParameters['PassThru'] ) { $null = $PSBoundParameters.Remove('PassThru') }
- # END PARAMETER MAP
-
- $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Update-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
- $scriptCmd = {& $wrappedCmd @PSBoundParameters }
-
- $steppablePipeline = $scriptCmd.GetSteppablePipeline()
- $steppablePipeline.Begin($PSCmdlet)
- } catch {
- throw
- }
-}
-
-process
-{
- try {
- $steppablePipeline.Process($_)
- } catch {
- throw
- }
-}
-
-end
-{
- try {
- $steppablePipeline.End()
- } catch {
- throw
- }
-}
-<#
-
-.ForwardHelpTargetName Update-Module
-.ForwardHelpCategory Function
-
-#>
-
-}
-
-function Update-ScriptProxy {
-[Alias('Update-Script')]
-[CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium', HelpUri='https://go.microsoft.com/fwlink/?LinkId=619787')]
-param(
- [Parameter(Position=0, ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [string[]]
- ${Name},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${RequiredVersion},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNull()]
- [string]
- ${MaximumVersion},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [ValidateNotNullOrEmpty()]
- [uri]
- ${Proxy},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${ProxyCredential},
-
- [Parameter(ValueFromPipelineByPropertyName=$true)]
- [pscredential]
- [System.Management.Automation.CredentialAttribute()]
- ${Credential},
-
- [switch]
- ${Force},
-
- [switch]
- ${AllowPrerelease},
-
- [switch]
- ${AcceptLicense},
-
- [switch]
- ${PassThru})
-
-begin
-{
- Write-Warning -Message "The cmdlet 'Update-Script' is deprecated, please use 'Update-PSResource'."
- try {
- $outBuffer = $null
- if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
- {
- $PSBoundParameters['OutBuffer'] = 1
- }
-
- # PARAMETER MAP
- $PSBoundParameters['Type'] = 'script'
- # handle version changes
- $verArgs = @{}
- if ( $PSBoundParameters['MaximumVersion'] ) { $null = $PSBoundParameters.Remove('MaximumVersion'); $verArgs['MaximumVersion'] = $MaximumVersion }
- if ( $PSBoundParameters['RequiredVersion'] ) { $null = $PSBoundParameters.Remove('RequiredVersion'); $verArgs['RequiredVersion'] = $RequiredVersion }
- $ver = Convert-VersionsToNugetVersion @verArgs
- if ( $ver ) {
- $PSBoundParameters['Version'] = $ver
- }
-
- # Parameter translations
- if ( $PSBoundParameters['AllowPrerelease'] ) { $null = $PSBoundParameters.Remove('AllowPrerelease'); $PSBoundParameters['Prerelease'] = $AllowPrerelease }
- # Parameter Deletions (unsupported in v3)
- if ( $PSBoundParameters['Proxy'] ) { $null = $PSBoundParameters.Remove('Proxy') }
- if ( $PSBoundParameters['ProxyCredential'] ) { $null = $PSBoundParameters.Remove('ProxyCredential') }
- if ( $PSBoundParameters['PassThru'] ) { $null = $PSBoundParameters.Remove('PassThru') }
- # END PARAMETER MAP
-
- $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Update-PSResource', [System.Management.Automation.CommandTypes]::Cmdlet)
- $scriptCmd = {& $wrappedCmd @PSBoundParameters }
-
- $steppablePipeline = $scriptCmd.GetSteppablePipeline()
- $steppablePipeline.Begin($PSCmdlet)
- } catch {
- throw
- }
-}
-
-process
-{
- try {
- $steppablePipeline.Process($_)
- } catch {
- throw
- }
-}
-
-end
-{
- try {
- $steppablePipeline.End()
- } catch {
- throw
- }
-}
-<#
-
-.ForwardHelpTargetName Update-Script
-.ForwardHelpCategory Function
-
-#>
-
-}
-
-$functionsToExport = @(
- "Find-CommandProxy",
- "Find-DscResourceProxy",
- "Find-ModuleProxy",
- "Find-RoleCapabilityProxy",
- "Find-ScriptProxy",
- "Get-InstalledModuleProxy",
- "Get-InstalledScriptProxy",
- "Get-PSRepositoryProxy",
- "Install-ModuleProxy",
- "Install-ScriptProxy",
- "Publish-ModuleProxy",
- "Publish-ScriptProxy",
- "Register-PSRepositoryProxy",
- "Save-ModuleProxy",
- "Save-ScriptProxy",
- "Set-PSRepositoryProxy",
- "Uninstall-ModuleProxy",
- "Uninstall-ScriptProxy",
- "Unregister-PSRepositoryProxy",
- "Update-ModuleProxy",
- "Update-ScriptProxy"
-)
-
-$aliasesToExport = @(
- "Find-Command",
- "Find-DscResource",
- "Find-Module",
- "Find-RoleCapability",
- "Find-Script",
- "Get-InstalledModule",
- "Get-InstalledScript",
- "Get-PSRepository",
- "Install-Module",
- "Install-Script",
- "Publish-Module",
- "Publish-Script",
- "Register-PSRepository",
- "Save-Module",
- "Save-Script",
- "Set-PSRepository",
- "Uninstall-Module",
- "Uninstall-Script",
- "Unregister-PSRepository",
- "Update-Module",
- "Update-Script"
-)
-
-export-ModuleMember -Function $functionsToExport -Alias $aliasesToExport