From 8dd417e46cf9ba3546b59a71970dfa476db22e15 Mon Sep 17 00:00:00 2001 From: Amber Erickson Date: Mon, 5 Aug 2019 18:04:07 -0700 Subject: [PATCH 01/11] add prototype for repository cmdlets and validation --- v3prototype/RepositoryManagement.ps1 | 260 ++++++++++++++++++++++++++ v3prototype/RepositoryValidations.ps1 | 112 +++++++++++ 2 files changed, 372 insertions(+) create mode 100644 v3prototype/RepositoryManagement.ps1 create mode 100644 v3prototype/RepositoryValidations.ps1 diff --git a/v3prototype/RepositoryManagement.ps1 b/v3prototype/RepositoryManagement.ps1 new file mode 100644 index 00000000..0d519543 --- /dev/null +++ b/v3prototype/RepositoryManagement.ps1 @@ -0,0 +1,260 @@ + +function Register-PSResourceRepository { + [OutputType([void])] + [Cmdletbinding(SupportsShouldProcess = $true, + DefaultParameterSetName = 'NameParameterSet')] + Param + ( + [Parameter(Mandatory = $true, + Position = 0, + ParameterSetName = 'NameParameterSet')] + [ValidateNotNullOrEmpty()] + [string] + $Name, + + [Parameter(Mandatory = $true, + Position = 1, + ParameterSetName = 'NameParameterSet')] + [ValidateNotNullOrEmpty()] + [Uri] + $URL, + + [Parameter(ValueFromPipelineByPropertyName = $true, + ParameterSetName = 'NameParameterSet')] + [PSCredential] + $Credential, + + [Parameter(Mandatory = $true, + ParameterSetName = 'PSGalleryParameterSet')] + [Switch] + $PSGallery, + + [Parameter(ParameterSetName = 'RepositoriesParameterSet')] + [ValidateNotNullOrEmpty()] + [Hashtable] + $Repositories, + + [Parameter()] + [Switch] + $Trusted, + + [Parameter(ValueFromPipelineByPropertyName = $true)] + [ValidateNotNullOrEmpty()] + [Uri] + $Proxy, + + [Parameter(ValueFromPipelineByPropertyName = $true)] + [PSCredential] + $ProxyCredential, + + [Parameter()] + [ValidateRange(0, 50)] + [int] + $Priority = 25 + ) + + begin { } + process { + + if ($PSCmdlet.ParameterSetName -eq 'PSGalleryParameterSet') { + if (-not $PSGallery) { + return + } + + #Register PSGallery + write-verbose -message "Successfully registered the repository PSGallery" + } + elseif ($PSCmdlet.ParameterSetName -eq 'RepositoriesParameterSet') { + foreach ($repo in $Repositories) { + + if ($pscmdlet.ShouldProcess($repo)) { + #Register each repository in the hashtable + $PSResourceRepository = [PSCustomObject] @{ + Name = $repo.Name + URL = $repo.URL + Trusted = $repo.Trusted + Priority = $repo.Priority + } + + write-verbose -message "Successfully registered the repository $repo" + } + } + } + else { + if ($pscmdlet.ShouldProcess($Name)) { + + #Register the repository + $PSResourceRepository = [PSCustomObject] @{ + Name = $Name + URL = $URL + Trusted = $Trusted + Priority = $Priority + } + + write-verbose -message "Successfully registered the repository $Name" + } + } + } + end { } +} + + +function Get-PSResourceRepository { + [OutputType([PSCustomObject])] + [Cmdletbinding(SupportsShouldProcess = $true)] + Param + ( + [Parameter(ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true)] + [ValidateNotNullOrEmpty()] + [string[]] + $Name + ) + + begin { } + process { + foreach ($n in $name) { + if ($pscmdlet.ShouldProcess($n)) { + + #Find and return repository + $PSResourceRepository = [PSCustomObject] @{ + Name = $Name + URL = "placeholder-for-url" + Trusted = "placeholder-for-trusted" + Priority = "placeholder-for-priority" + } + + return $PSResourceRepository + } + } + } + end { } +} + + +function Set-PSResourceRepository { + [OutputType([void])] + [Cmdletbinding(SupportsShouldProcess = $true)] + Param + ( + [Parameter(Mandatory = $true, + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, + Position = 0)] + [ValidateNotNullOrEmpty()] + [string] + $Name, + + [Parameter(ValueFromPipelineByPropertyName = $true, + Position = 1)] + [ValidateNotNullOrEmpty()] + [Uri] + $URL, + + [Parameter(ValueFromPipelineByPropertyName = $true)] + [PSCredential] + $Credential, + + [Parameter()] + [Switch] + $Trusted, + + [Parameter(ValueFromPipelineByPropertyName = $true)] + [ValidateNotNullOrEmpty()] + [Uri] + $Proxy, + + [Parameter(ValueFromPipelineByPropertyName = $true)] + [PSCredential] + $ProxyCredential, + + [Parameter(ValueFromPipelineByPropertyName = $true, + ParameterSetName = 'RepositoriesParameterSet')] + [ValidateNotNullOrEmpty()] + [Hashtable] + $Repositories, + + [Parameter(ValueFromPipelineByPropertyName = $true)] + [ValidateRange(0, 50)] + [int] + $Priority + ) + + + begin { } + process { + + if ($PSCmdlet.ParameterSetName -eq 'RepositoriesParameterSet') { + + foreach ($repo in $Repositories) { + if ($pscmdlet.ShouldProcess($repo)) { + + $repository = Get-PSResourceRepository + + if (-not $repository) { + ThrowError -ExceptionMessage "This repository could not be found." + return + } + + #Set repository properties + $PSResourceRepository = [PSCustomObject] @{ + Name = $repo.Name + URL = $repo.URL + Trusted = $repo.Trusted + Priority = $repo.Priority + } + write-verbose -message "Successfully set the $repo repository." + } + } + } + else { + if ($pscmdlet.ShouldProcess($Name)) { + + $repository = Get-PSResourceRepository + + if (-not $repository) { + ThrowError -ExceptionMessage "This repository could not be found." + return + } + + #Set repository properties + $PSResourceRepository = [PSCustomObject] @{ + Name = $Name + URL = $URL + InstallationPolicy = $InstallationPolicy + Priority = $Priority + } + + write-verbose "Successfully set the $Name repository." + } + } + } + end { } +} + + +function Unregister-PSResourceRepository { + [OutputType([void])] + [Cmdletbinding(SupportsShouldProcess = $true)] + Param + ( + [Parameter(Mandatory = $true, + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, + Position = 0)] + [ValidateNotNullOrEmpty()] + [string[]] + $Name + ) + + begin { } + process { + foreach ($n in $name) { + if ($pscmdlet.ShouldProcess($n)) { + #Unregister the each repository + write-verbose -message "Successfully unregistered $n" + } + } + } + end { } +} diff --git a/v3prototype/RepositoryValidations.ps1 b/v3prototype/RepositoryValidations.ps1 new file mode 100644 index 00000000..fc846baf --- /dev/null +++ b/v3prototype/RepositoryValidations.ps1 @@ -0,0 +1,112 @@ +##################################### +### Register-PSResourceRepository ### +##################################### +# Should register the PowerShell Gallery +Register-PSRepository -PSGallery + +# Should register the repository "TestRepo" +Register-PSResourceRepository "TestRepo" "www.testrepo.com" + +# Should register the repository "TestRepo" +Register-PSResourceRepository -name "TestRepo" -url "www.testrepo.com" + +# Should register the repository "TestRepo" as trusted, priority should be set to 0 +Register-PSResourceRepository -name "TestRepo" -url "www.testrepo.com" -Trusted + +# Should register the repository "TestRepo" with a priority of 2 +Register-PSResourceRepository -name "TestRepo" -url "www.testrepo.com" -Priority 2 + +### Repositories +# Should register the repositories "TestRepo1", "TestRepo2", "PSGallery" +Register-PSResourceRepository -Repositories @( + @{ Name = "TestRepo1"; URL = "https://testrepo1.com"; Trusted = $true; Credential = $cred } + @{ Name = "TestRepo2"; URL = "\\server\share\myrepository"; Trusted = $true } + @{ Default = $true; Trusted = $true } +) + +# Should return the repositories "TestRepo1", "TestRepo2", "PSGallery" +$repos = @( + @{ Name = "TestRepo1"; URL = "https://testrepo1.com"; Trusted = $true; } + @{ Name = "TestRepo2"; URL = "\\server\share\myrepository"; Trusted = $true } + @{ Default = $true; Trusted = $true } +) +$repos | Register-PSResourceRepository + + + +################################ +### Get-PSResourceRepository ### +################################ +# Should return all repositories +Get-PSResourceRepository + +# Should return the repository "TestRepo" +Get-PSResourceRepository "TestRepo" + +# Should return the repository "TestRepo" +Get-PSResourceRepository -name "TestRepo" + +# Should return the repositories "TestRepo1", "TestRepo2", "TestRepo3" +Get-PSResourceRepository "TestRepo1", "TestRepo2", "TestRepo3" + +# Should return the repositories "TestRepo1", "TestRepo2", "TestRepo3" +Get-PSResourceRepository -name "TestRepo1", "TestRepo2", "TestRepo3" + +# Should return the repository "TestRepo" +"TestRepo1" | Get-PSResourceRepository + +# Should return the repositories "TestRepo1", "TestRepo2", "TestRepo3" +"TestRepo1", "TestRepo2", "TestRepo3" | Get-PSResourceRepository + + + +################################ +### Set-PSResourceRepository ### +################################ +# Should set the repository "TestRepo" to the url "www.testrepo.com" +Set-PSResourceRepository "TestRepo" "www.testrepo.com" + +# Should set the repository "TestRepo" to the url "www.testrepo.com" +Set-PSResourceRepository -name "TestRepo" -url "www.testrepo.com" + +# Should set the repository "TestRepo" to trusted, with a priority of 0 +Set-PSResourceRepository "TestRepo" -Trusted + +# Should set the repository "TestRepo" with a priority of 2 +Set-PSResourceRepository "TestRepo" "www.testrepo.com" -Priority 2 + +# Should set the repository "TestRepo" +"TestRepo1" | Set-PSResourceRepository -url "www.testrepo.com" + +### Repositories +# Should set the repositories "TestRepo1", "TestRepo2", "PSGallery" to trusted, with a priority of 0 +Set-PSResourceRepository -Repositories @( + @{ Name = "TestRepo1"; URL = "https://testrepo1.com"; Trusted = $true; } + @{ Name = "TestRepo2"; URL = "\\server\share\myrepository"; Trusted = $true } + @{ Default = $true; Trusted = $true } +) + +# Should return the repositories "TestRepo1", "TestRepo2", "PSGallery" +$repos = @( + @{ Name = "TestRepo1"; URL = "https://testrepo1.com"; Trusted = $true; } + @{ Name = "TestRepo2"; URL = "\\server\share\myrepository"; Trusted = $true } + @{ Default = $true; Trusted = $true } +) +$repos | Set-PSResourceRepository + + + +####################################### +### Unregister-PSResourceRepository ### +####################################### +# Should unregister the repository "TestRepo" +Unregister-PSResourceRepository -name "TestRepo" + +# Should unregister the repositories "TestRepo1", "TestRepo2", "TestRepo3" +Unregister-PSResourceRepository -name "TestRepo1", "TestRepo2", "TestRepo3" + +# Should unregister the repository "TestRepo" +"TestRepo1" | Unregister-PSResourceRepository + +# Should unregister the repositories "TestRepo1", "TestRepo2", "TestRepo3" +"TestRepo1", "TestRepo2", "TestRepo3" | Unregister-PSResourceRepository From bb20d0fc593c2dc1020cf740fc1f537990cb0916 Mon Sep 17 00:00:00 2001 From: Amber Erickson Date: Mon, 12 Aug 2019 15:51:05 -0700 Subject: [PATCH 02/11] Add Find-PSResource cmdlet and validations --- v3prototype/Find-PSResource.ps1 | 182 +++++++++++++++ v3prototype/PSResourceValidation.ps1 | 325 +++++++++++++++++++++++++++ 2 files changed, 507 insertions(+) create mode 100644 v3prototype/Find-PSResource.ps1 create mode 100644 v3prototype/PSResourceValidation.ps1 diff --git a/v3prototype/Find-PSResource.ps1 b/v3prototype/Find-PSResource.ps1 new file mode 100644 index 00000000..6ff14f50 --- /dev/null +++ b/v3prototype/Find-PSResource.ps1 @@ -0,0 +1,182 @@ +# Replaces: Find-Command, Find-DscResource, Find-Module, Find-RoleCapability, Find-Script +# Parameter Sets: ResourceParameterSet, PackageParameterSet, ScriptParameterSet + +# Find-Command returns an object with properties: Name, Version, ModuleName, Repository +# Find-DSCResource returns an object with properties: Name, Version, ModuleName, Repository +# Find-RoleCapability returns an object with properties: Name, Version, ModuleName, Repository + +# Find-Module returns an object with properties: Version, Name, Repository, Description +# Find-Script returns an object with properties: Version, Name, Repository, Description +function Find-PSResource +{ + [OutputType([PSCustomObject[]])] + [Cmdletbinding(SupportsShouldProcess = $true)] + Param + ( + # Specifies the name of the resource to be searched for. + # Resources that use this param: Command, DSCResource, RoleCapability, Package, Script. + [Parameter(ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, + Position = 0)] + [ValidateNotNullOrEmpty()] + [string[]] + $Name, + + # Specifies the type of the resource being searched. + # Resources that use this param: Command, DSCResource, RoleCapability, Package, Script. + [Parameter(ValueFromPipelineByPropertyName = $true)] + [ValidateSet('Module', 'Script', 'DscResource', 'RoleCapability', 'Command')] + [string[]] + $Type, + + # Specifies the module name that contains the resource. + # Resources that use this param: Command, DSCResource, RoleCapability. + [Parameter(ParameterSetName = "ResourceParameterSet")] + [ValidateNotNullOrEmpty()] + [string] + $ModuleName, + + # Specifies the minimum version of the resource to include in results (cannot use this parameter with the RequiredVersion or AllVersions parameters). + # Resources that use this param: Command, DSCResource, RoleCapability, Package, Script. + [Parameter(ValueFromPipelineByPropertyName = $true)] + [ValidateNotNull()] + [string] + $MinimumVersion, + + # Specifies the maximum version of the resource to include in results (cannot use this parameter with the RequiredVersion or AllVersions parameters). + # Resources that use this param: Command, DSCResource, RoleCapability, Package, Script. + [Parameter(ValueFromPipelineByPropertyName = $true)] + [ValidateNotNull()] + [string] + $MaximumVersion, + + # Specifies the required version of the resource to include in results (cannot use this parameter with the MinimumVersion, MaximumVersion, or AllVersions parameters). + # Resources that use this param: Command, DSCResource, RoleCapability, Package, Script. + [Parameter(ValueFromPipelineByPropertyName = $true)] + [ValidateNotNull()] + [string] + $RequiredVersion, + + # Displays each of a resource's available versions (cannot use this parameter with the MinimumVersion, MaximumVersion, or RequiredVersion parameters). + # Resources that use this param: Command, DSCResource, RoleCapability, Package, Script. + [Parameter()] + [switch] + $AllVersions, + + # Includes resources marked as a prerelease. + # Resources that use this param: Command, DSCResource, RoleCapability, Package, Script. + [Parameter()] + [switch] + $Prerelease, + + # Specifies tags that categorize modules in a repository. + # Resources that use this param: Command, DSCResource, RoleCapability, Package, Script. + [Parameter()] + [ValidateNotNull()] + [string[]] + $Tag, + + # Finds resources based on ModuleName, Description, and Tag properties. + # Resources that use this param: Command, DSCResource, RoleCapability, Package, Script. + [Parameter()] + [ValidateNotNull()] + [string] + $Filter, + + # Specifies a proxy server for the request, rather than a direct connection to the internet resource. + # Resources that use this param: Command, DSCResource, RoleCapability, Package, Script. + [Parameter(ValueFromPipelineByPropertyName = $true)] + [ValidateNotNullOrEmpty()] + [Uri] + $Proxy, + + # Specifies a user account that has permission to use the proxy server that is specified by the Proxy parameter. + # Resources that use this param: Command, DSCResource, RoleCapability, Package, Script. + [Parameter(ValueFromPipelineByPropertyName = $true)] + [PSCredential] + $ProxyCredential, + + # Specifies the repository to search within (default is all repositories). + # Resources that use this param: Command, DSCResource, RoleCapability, Package, Script. + [Parameter()] + [ValidateNotNullOrEmpty()] + [string[]] + $Repository, + + # Specifies a user account that has rights to install a module for a specified package provider or source. + # Resources that use this param: Package, Script. + [Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = "PackageParameterSet")] + [Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = "ScriptParameterSet")] + [PSCredential] + $Credential, + + # Specifies to include all modules that are dependent upon the module specified in the Name parameter. + # Resources that use this param: Package, Script. + [Parameter(ParameterSetName = "PackageParameterSet")] + [Parameter(ParameterSetName = "ScriptParameterSet")] + [switch] + $IncludeDependencies, + + # Returns only those modules that include specific kinds of PowerShell functionality. For example, you might only want to find modules that include DSCResource. + # The acceptable values for this parameter are as follows: + # Module: DscResource, Cmdlet, Function, RoleCapability; + # Scripts: Function, Workflow; + # Resources that use this param: Package, Script. + [Parameter(ParameterSetName = "PackageParameterSet")] + [Parameter(ParameterSetName = "ScriptParameterSet")] + [ValidateNotNull()] + [ValidateSet('DscResource', 'Cmdlet', 'Function', 'RoleCapability', 'Workflow')] + [string[]] + $Includes, + + # Specifies the name of the DSC resources contained within a module (per PowerShell conventions, performs an OR search when you provide multiple arguments). + # Resources that use this param: Package. + [Parameter(ParameterSetName = "PackageParameterSet")] + [ValidateNotNull()] + [string[]] + $DscResource, + + # Specifies the name of the role capabilities contained within a module (per PowerShell conventions, performs an OR search when you provide multiple arguments). + # Resources that use this param: Package. + [Parameter(ParameterSetName = "PackageParameterSet")] + [ValidateNotNull()] + [string[]] + $RoleCapability, + + # Specifies commands to find in modules (command can be a function or workflow). + # Resources that use this param: Package, Script. + [Parameter(ParameterSetName = "PackageParameterSet")] + [Parameter(ParameterSetName = "ScriptParameterSet")] + [ValidateNotNull()] + [string[]] + $Command + + ) + + begin{ + #For each repository, if local cache does not exist then Update-PSResourceCache + } + process{ + + # Returning the array of resources + $foundResources + + foreach ($n in $name){ + + if ($pscmdlet.ShouldProcess($n)) { + + $PSResource = [PSCustomObject] @{ + Name = $Name + Version = "placeholder-for-module-version" + Type = $Type + Description = "placeholder-for-description" + } + + $foundResources += $PSResource + } + } + + return $foundResources + } + end{} +} \ No newline at end of file diff --git a/v3prototype/PSResourceValidation.ps1 b/v3prototype/PSResourceValidation.ps1 new file mode 100644 index 00000000..d357ab0f --- /dev/null +++ b/v3prototype/PSResourceValidation.ps1 @@ -0,0 +1,325 @@ +####################### +### Find-PSResource ### +####################### + +### Find command ### +# Should find the command "TestCommand" +Find-PSResource -name "TestCommand" + +# Should find the command "TestCommand" +Find-PSResource "TestCommand" + +# Should find the command "TestCommand" +Find-PSResource "TestCommand" -Type "Command" + +# Should find the command "TestCommand" +Find-PSResource "TestCommand" -Type "Command","DscResource", "RoleCapability","Module", "Script" + +# Should find the command "TestCommand" from all the modules with name "TestCommandModuleName" (default to the latest [minor?] version) +Find-PSResource -name "TestCommand" -ModuleName "TestCommandModuleName" + +# Should find the command "TestCommand" from all the modules with name "TestCommandModuleName" that have a minimum version 1.5.0, not including prerelease versions +Find-PSResource -name "TestCommand" -ModuleName "TestCommandModuleName" -MinimumVersion "1.5.0" + +# Should find the command "TestCommand" from all the modules with name "TestCommandModuleName" that have a maximum version of 1.5.0, not including prerelease versions +Find-PSResource -name "TestCommand" -ModuleName "TestCommandModuleName" -MaximumVersion "1.5.0" + +# Should find the command "TestCommand" from all the modules with name "TestCommandModuleName" that have a minimum version of 1.0.0 and a maximum version of 2.0.0, not including prerelease versions +Find-PSResource -name "TestCommand" -ModuleName "TestCommandModuleName" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" + +# Should find the command "TestCommand" from all the modules with name "TestCommandModuleName" that have a required version of 1.5.0, not including prerelease versions +Find-PSResource -name "TestCommand" -ModuleName "TestCommandModuleName" -RequiredVersion "1.5.0" + +# Should find the command "TestCommand" from all versions of the module "TestCommandModuleName", not including prerelease versions +Find-PSResource -name "TestCommand" -ModuleName "TestCommandModuleName" -AllVersions + +# Should find the command "TestCommand" from the resource (latest version), including prerelease versions +Find-PSResource -name "TestCommand" -ModuleName "TestCommandModuleName" -AllowPrerelease + +# Should find the command "TestCommand" from a resource with the tags "Tag1", "Tag2", "Tag3" +Find-PSResource -name "TestCommand" -Tag "Tag1","Tag2","Tag3" + +# Should find the command "TestCommand" from a resource that has "Test" in either the module name or description +Find-PSResource -name "TestCommand" -Filter "Test" + +# Should find the command "TestCommand" from one of the specified repositories +Find-PSResource -name "TestCommand" -Repository "Repository1", "Repository2" + +# Should NOT find the command "TestCommand" +Find-PSResource "TestCommand" -Type "TestDscResource" + + + +### Find DSC resource ### +# Should find the DSC resource "TestDscResource" +Find-PSResource -name "TestDscResource" + +# Should find the DSC resource "TestDscResource" +Find-PSResource "TestDscResource" + +# Should find the DSC resource "TestDscResource" +Find-PSResource "TestDscResource" -Type "DscResource" + +# Should find the DSC resource "TestDscResource" +Find-PSResource "TestDscResource" -Type "Command","DscResource", "RoleCapability","Module", "Script" + +# Should find the DSC resource "TestDscResource" that is contained within the module "TestDscResourceModuleName" (default to the latest [minor?] version) +Find-PSResource -name "TestDscResource" -ModuleName "TestDscResourceModuleName" + +# Should find the DSC resource "TestDscResource" from all the modules with name "TestDscResourceModuleName" that have a minimum version 1.5.0, not including prerelease versions +Find-PSResource -name "TestDscResource" -ModuleName "TestDscResourceModuleName" -MinimumVersion "1.5.0" + +# Should find the DSC resource "TestDscResource" from all the modules with name "TestDscResourceModuleName" that have a maximum version of 1.5.0, not including prerelease versions +Find-PSResource -name "TestDscResource" -ModuleName "TestDscResourceModuleName" -MaximumVersion "1.5.0" + +# Should find the command "TestDscResource" from all the modules with name "TestDscResourceModuleName" that have a minimum version of 1.0.0 and a maximum version of 2.0.0, not including prerelease versions +Find-PSResource -name "TestDscResource" -ModuleName "TestDscResourceModuleName" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" + +# Should find the DSC resource "TestDscResource" from all the modules with name "TestDscResourceModuleName" that have a required version of 1.5.0, not including prerelease versions +Find-PSResource -name "TestDscResource" -ModuleName "TestDscResourceModuleName" -RequiredVersion "1.5.0" + +# Should find the DSC resource "TestDscResource" from all versions of the module "TestDscResourceModuleName", not including prerelease versions +Find-PSResource -name "TestDscResource" -ModuleName "TestDscResourceModuleName" -AllVersions + +# Should find the DSC resource "TestDscResource" from the resource (latest version), including prerelease versions +Find-PSResource -name "TestDscResource" -ModuleName "TestDscResourceModuleName" -AllowPrerelease + +# Should find the DSC resource "TestDscResource" from a resource with the tags "Tag1", "Tag2", "Tag3" +Find-PSResource -name "TestDscResource" -Tag "Tag1","Tag2","Tag3" + +# Should find the DSC resource "TestDscResource" from a resource that has "Test" in either the module name or description +Find-PSResource -name "TestDscResource" -Filter "Test" + +# Should find the DSC resource "TestDscResource" from one of the specified repositories +Find-PSResource -name "TestDscResource" -Repository "Repository1", "Repository2" + +# Should NOT find the DSC resource "TestDscResource" +Find-PSResource "TestDscResource" -Type "DscResource" + + + +### Find role capability ### +# Should find the role capability "TestRoleCapability" +Find-PSResource -name "TestRoleCapability" + +# Should find the role capability "TestRoleCapability" +Find-PSResource "TestRoleCapability" + +# Should find the role capability "TestRoleCapability" +Find-PSResource "TestRoleCapability" -Type "DscResource" + +# Should find the role capability "TestRoleCapability" +Find-PSResource "TestRoleCapability" -Type "Command","DscResource", "RoleCapability","Module", "Script" + +# Should find the role capability "TestRoleCapability" from the module (default to the latest [minor?] version) +Find-PSResource -name "TestRoleCapability" -ModuleName "TestDscResourceModuleName" + +# Should find the role capability "TestRoleCapability" from all the modules with name "TestDscResourceModuleName" that have a minimum version 1.5.0, not including prerelease versions +Find-PSResource -name "TestRoleCapability" -ModuleName "TestDscResourceModuleName" -MinimumVersion "1.5.0" + +# Should find the role capability "TestRoleCapability" from all the modules with name "TestDscResourceModuleName" that have a maximum version of 1.5.0, not including prerelease versions +Find-PSResource -name "TestRoleCapability" -ModuleName "TestDscResourceModuleName" -MaximumVersion "1.5.0" + +# Should find the command "TestRoleCapability" from all the modules with name "TestDscResourceModuleName" that have a minimum version of 1.0.0 and a maximum version of 2.0.0, not including prerelease versions +Find-PSResource -name "TestRoleCapability" -ModuleName "TestDscResourceModuleName" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" + +# Should find the role capability "TestRoleCapability" from all the modules with name "TestDscResourceModuleName" that have a required version of 1.5.0, not including prerelease versions +Find-PSResource -name "TestRoleCapability" -ModuleName "TestDscResourceModuleName" -RequiredVersion "1.5.0" + +# Should find the role capability "TestRoleCapability" from the resource (lists all versions), not including prerelease versions +Find-PSResource -name "TestRoleCapability" -ModuleName "TestDscResourceModuleName" -AllVersions + +# Should find the role capability "TestRoleCapability" from the resource (latest version), including prerelease versions +Find-PSResource -name "TestRoleCapability" -ModuleName "TestDscResourceModuleName" -AllowPrerelease + +# Should find the role capability "TestRoleCapability" from a resource with the tags "Tag1", "Tag2", "Tag3" +Find-PSResource -name "TestRoleCapability" -Tag "Tag1","Tag2","Tag3" + +# Should find the role capability "TestRoleCapability" from a resource that has "Test" in either the module name or description +Find-PSResource -name "TestRoleCapability" -Filter "Test" + +# Should find the role capability "TestRoleCapability" from one of the specified repositories +Find-PSResource -name "TestRoleCapability" -Repository "Repository1", "Repository2" + +# Should NOT find the role capability "TestRoleCapability" +Find-PSResource "TestRoleCapability" -Type "TestDscResource" + + + +### Find module ### +# Should find the module "TestModule" +Find-PSResource -name "TestModule" + +# Should find the module "TestModule" +Find-PSResource "TestModule" + +# Should find the module "TestModule" +Find-PSResource "TestModule" -Type "Module" + +# Should find the module "TestModule" +Find-PSResource "TestModule" -Type "Command","DscResource", "RoleCapability","Module", "Script" + +# Should find all modules named "TestModule" that have a minimum version of 1.5.0, not including prerelease versions +Find-PSResource -name "TestModule" -MinimumVersion "1.5.0" + +# Should find all modules named "TestModule" that have a maximum version of 1.5.0, not including prerelease versions +Find-PSResource -name "TestModule" -MaximumVersion "1.5.0" + +# Should find all modules named "TestModule" that have a minimum version of 1.0.0 and a maximum version of 1.5.0, not including prerelease versions +Find-PSResource -name "TestModule" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" + +# Should find all the modules named "TestModule" that is version 1.5.0 +Find-PSResource -name "TestModule" -RequiredVersion "1.5.0" + +# Should find all versions of all modules named "TestModule", not including prerelease versions +Find-PSResource -name "TestModule" -AllVersions + +# Should find all modules named "TestModule", including prerelease versions +Find-PSResource -name "TestModule" -AllowPrerelease + +# Should find all the modules named "TestModule" with the tags "Tag1", "Tag2", "Tag3" +Find-PSResource -name "TestModule" -Tag "Tag1","Tag2","Tag3" + +# Should find all the modules named "TestModule" that have "Test" in either the module name or description +Find-PSResource -name "TestModule" -Filter "Test" + +# Should find all the modules named "TestModule" from all of the specified repositories +Find-PSResource -name "TestModule" -Repository "Repository1", "Repository2" + +# Should find all the modules named "TestModule" and all modules that are dependent upon "TestModule" +Find-PSResource -name "TestModule" -IncludeDependencies + +# Should find all the modules named "TestModule" that have DSC resources +Find-PSResource -name "TestModule" -Includes 'DscResource' + +# Should find all the modules named "TestModule" that have DSC resources named "TestDscResource" +Find-PSResource -name "TestModule" -DSCResource "TestDscResource" + +# Should find all the modules named "TestModule" that have a role capacity named "TestDscResource" +Find-PSResource -name "TestModule" -RoleCapability "TestRoleCapability" + +# Should find all the modules named "TestModule" that have a command named "Test-Command" +Find-PSResource -name "TestModule" -Command "Test-Command" + + + +### Find Script ### +# Should find all scripts named "TestScript" +Find-PSResource -name "TestScript" + +# Should find all scripts named "TestScript" +Find-PSResource "TestScript" + +# Should find all scripts named "TestScript" +Find-PSResource "TestScript" -Type "Script" + +# Should find all scripts named "TestScript" +Find-PSResource "TestScript" -Type "Command","DscResource", "RoleCapability","Module", "Script" + +# Should find all scripts named "TestScript" that have a minimum version of 1.5.0, not including prerelease versions +Find-PSResource -name "TestScript" -MinimumVersion "1.5.0" + +# Should find all scripts named "TestScript" that have a maximum version of 1.5.0, not including prerelease versions +Find-PSResource -name "TestScript" -MaximumVersion "1.5.0" + +# Should find all scripts named "TestScript" that have a minimum version of 1.0.0 and a maximum version of 1.5.0, not including prerelease versions +Find-PSResource -name "TestScript" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" + +# Should find all the scripts named "TestScript" that is version 1.5.0 +Find-PSResource -name "TestScript" -RequiredVersion "1.5.0" + +# Should find all versions of all scripts named "TestScript", not including prerelease versions +Find-PSResource -name "TestScript" -AllVersions + +# Should find all scripts named "TestScript", including prerelease versions +Find-PSResource -name "TestScript" -AllowPrerelease + +# Should find all the scripts named "TestScript" with the tags "Tag1", "Tag2", "Tag3" +Find-PSResource -name "TestScript" -Tag "Tag1","Tag2","Tag3" + +# Should find all the scripts named "TestScript" that have "Test" in either the script name or description +Find-PSResource -name "TestScript" -Filter "Test" + +# Should find all the scripts named "TestScript" from all of the specified repositories +Find-PSResource -name "TestScript" -Repository "Repository1", "Repository2" + +# Should find all the scripts named "TestScript" and all modules that are dependent upon "TestScript" +Find-PSResource -name "TestScript" -IncludeDependencies + +# Should find all the scripts named "TestScript" that have a function named "TestFunction" +Find-PSResource -name "TestScript" -Includes 'TestFunction' + +# Should find all the modules named "TestScript" that have a command named "Test-Command" +Find-PSResource -name "TestScript" -Command "Test-Command" + + + +### Find multiple resources ### +# Should find the resources "TestResource1", "TestResource2", "TestResource3" +Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" + +# Should find the resource "TestResource1", "TestResource2", "TestResource3" +Find-PSResource "TestResource1", "TestResource2", "TestResource3" + +# Should find the resources "TestResource1", "TestResource2", "TestResource3" +Find-PSResource "TestResource1", "TestResource2", "TestResource3" -Type "Module" + +# Should find the "TestResource1", "TestResource2", "TestResource3" +Find-PSResource "TestResource1", "TestResource2", "TestResource3" -Type "Command","DscResource", "RoleCapability","Module", "Script" + +# Should find all modules named "TestResource1", "TestResource2", "TestResource3" that have a minimum version of 1.5.0, not including prerelease versions +Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -MinimumVersion "1.5.0" + +# Should find all modules named "TestResource1", "TestResource2", "TestResource3" that have a maximum version of 1.5.0, not including prerelease versions +Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -MaximumVersion "1.5.0" + +# Should find all modules named "TestResource1", "TestResource2", "TestResource3" that have a minimum version of 1.0.0 and a maximum version of 1.5.0, not including prerelease versions +Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" + +# Should find all the modules named "TestResource1", "TestResource2", "TestResource3" that is version 1.5.0 +Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -RequiredVersion "1.5.0" + +# Should find all versions of all modules named "TestResource1", "TestResource2", "TestResource3", not including prerelease versions +Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -AllVersions + +# Should find all modules named "TestResource1", "TestResource2", "TestResource3", including prerelease versions +Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -AllowPrerelease + +# Should find all the modules named "TestResource1", "TestResource2", "TestResource3" with the tags "Tag1", "Tag2", "Tag3" +Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -Tag "Tag1","Tag2","Tag3" + +# Should find all the modules named "TestResource1", "TestResource2", "TestResource3" that have "Test" in either the module name or description +Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -Filter "Test" + +# Should find all the modules named "TestResource1", "TestResource2", "TestResource3" from all of the specified repositories +Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -Repository "Repository1", "Repository2" + +# Should find all the modules named "TestResource1", "TestResource2", "TestResource3" and all modules that are dependent upon "TestResource1", "TestResource2", "TestResource3" +Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -IncludeDependencies + +# Should find all the modules named "TestResource1", "TestResource2", "TestResource3" that have DSC resources +Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -Includes 'DscResource' + +# Should find all the modules named "TestResource1", "TestResource2", "TestResource3" that have DSC resources named "TestDscResource" +Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -DSCResource "TestDscResource" + +# Should find all the modules named "TestResource1", "TestResource2", "TestResource3" that have a role capacity named "TestRoleCapacity" +Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -RoleCapability "TestRoleCapability" + +# Should find all the modules named "TestResource1", "TestResource2", "TestResource3" that have a command named "Test-Command" +Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -Command "Test-Command" + + + +########################## +### Install-PSResource ### +########################## + +### Installing Modules ### +Install-PSResource 'TestModule' -Repository 'https://mygallery.com' + +Install-PSResource 'TestModule1', 'TestModule2', 'TestModule3' -Repository 'https://mygallery.com' + + + +### Installing Scripts ### \ No newline at end of file From d4064e4f1d38db66149c2383cd039fdfa4ecd39e Mon Sep 17 00:00:00 2001 From: Amber Erickson Date: Tue, 13 Aug 2019 14:32:11 -0700 Subject: [PATCH 03/11] Add Install-PSResource cmd and validations --- v3prototype/Install-PSResource.ps1 | 180 ++++++++++++++++++ v3prototype/Install-PSResourceValidations.ps1 | 175 +++++++++++++++++ 2 files changed, 355 insertions(+) create mode 100644 v3prototype/Install-PSResource.ps1 create mode 100644 v3prototype/Install-PSResourceValidations.ps1 diff --git a/v3prototype/Install-PSResource.ps1 b/v3prototype/Install-PSResource.ps1 new file mode 100644 index 00000000..b7967d2e --- /dev/null +++ b/v3prototype/Install-PSResource.ps1 @@ -0,0 +1,180 @@ +# Replaces: Install-Module, Install-Script +# Parameter Sets: NameParameterSet, InputObject +# Install-PSResource will only work for modules unless -DestinationPath is specified which works for all resource types. +function Install-PSResource { + [OutputType([void])] + [cmdletbinding(SupportsShouldProcess = $true)] + Param + ( + # Specifies the exact names of resources to install from a repository. + # A comma-separated list of module names is accepted. The resource name must match the resource name in the repository. + [Parameter(Mandatory = $true, + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, + Position = 0, + ParameterSetName = 'NameParameterSet')] + [ValidateNotNullOrEmpty()] + [string[]] + $Name, + + # Used for pipeline input. + [Parameter(Mandatory = $true, + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, + Position = 0, + ParameterSetName = 'InputObject')] + [ValidateNotNull()] + [PSCustomObject[]] + $InputObject, + + # The destination where the resource is to be installed. Works for all resource types. + [Parameter(ValueFromPipelineByPropertyName = $true, + ParameterSetName = 'NameParameterSet')] + [ValidateNotNull()] + [string] + $DestinationPath, + + # Specifies the minimum version of the resource to be installed (cannot use this parameter with the RequiredVersion parameter). + [Parameter(ValueFromPipelineByPropertyName = $true, + ParameterSetName = 'NameParameterSet')] + [ValidateNotNull()] + [string] + $MinimumVersion, + + # Specifies the maximum version of the resource to include to be installed (cannot use this parameter with the RequiredVersion parameter). + [Parameter(ValueFromPipelineByPropertyName = $true, + ParameterSetName = 'NameParameterSet')] + [ValidateNotNull()] + [string] + $MaximumVersion, + + # Specifies the required version of the resource to include to be installed (cannot use this parameter with the MinimumVersion or MaximumVersion parameters). + [Parameter(ValueFromPipelineByPropertyName = $true, + ParameterSetName = 'NameParameterSet')] + [ValidateNotNull()] + [string] + $RequiredVersion, + + # Allows installing prerelease versions + [Parameter(ParameterSetName = 'NameParameterSet')] + [switch] + $Prerelease, + + # Specifies the repository to search within (default is all repositories). + [Parameter(ParameterSetName = 'NameParameterSet')] + [ValidateNotNullOrEmpty()] + [string[]] + $Repository, + + # If the resource requires dependencies that are not already installed, then a prompt will appear before anything is installed, + # listing all the resources including module name, version, size, and repository to be installed + # unless -IncludeDependencies is specified which will install without prompting. + # Rejecting the prompt will result in nothing being installed. + [Parameter()] + [switch] + $IncludeDependencies, + + # Accepts a path to a hashtable or json file. + # Where the key is the module name and the value is either the required version specified using Nuget version range syntax or + # a hash table where repository is set to the URL of the repository and version contains the Nuget version range syntax. + # The json format will be the same as if this hashtable is passed to ConvertTo-Json. + [Parameter(ParameterSetName = 'NameParameterSet')] + [ValidateNotNullOrEmpty()] + [string[]] + $RequiredResources, + + # Accepts a path to a psd1 or json file. + # See above for json description. + [Parameter(ParameterSetName = 'NameParameterSet')] + [ValidateNotNullOrEmpty()] + [string[]] + $RequiredResourcesFile, + + # Specifies the installation scope of the module. The acceptable values for this parameter are AllUsers and CurrentUser. Default is CurrentUser. + # The AllUsers scope installs modules in a location that is accessible to all users of the computer: + # $env:ProgramFiles\PowerShell\Modules + # The CurrentUser installs modules in a location that is accessible only to the current user of the computer: + # $home\Documents\PowerShell\Modules + # When no Scope is defined, the default is set based on the PowerShellGet version. + # In PowerShellGet versions 2.0.0 and above, the default is CurrentUser, which does not require elevation for install. + # In PowerShellGet 1.x versions, the default is AllUsers, which requires elevation for install. + [Parameter()] + [ValidateSet("CurrentUser", "AllUsers")] + [string] + $Scope, + + # Specifies a proxy server for the request, rather than connecting directly to the Internet resource. + [Parameter(ValueFromPipelineByPropertyName = $true)] + [ValidateNotNullOrEmpty()] + [Uri] + $Proxy, + + # Specifies a user account that has permission to use the proxy server that is specified by the Proxy parameter. + [Parameter(ValueFromPipelineByPropertyName = $true)] + [PSCredential] + $ProxyCredential, + + # Specifies a user account that has rights to install a module for a specified package provider or source. + [Parameter(ValueFromPipelineByPropertyName = $true)] + [PSCredential] + $Credential, + + # Overrides warning messages about installation conflicts about existing commands on a computer. + # Overwrites existing commands that have the same name as commands being installed by a module. AllowClobber and Force can be used together in an Install-Module command. + # Prevents installing modules that have the same cmdlets as a differently named module already + [Parameter()] + [switch] + $NoClobber, + + # Suppresses being prompted if the publisher of the resource is different from the currently installed version. + [Parameter()] + [switch] + $IgnoreDifferentPublisher, + + # Suppresses being prompted for untrusted sources. + [Parameter()] + [switch] + $TrustRepository, + + # Overrides warning messages about resource installation conflicts. + # If a resource with the same name already exists on the computer, Force allows for multiple versions to be installed. + # If there is an existing resource with the same name and version, Force does NOT overwrite that version. + [Parameter()] + [switch] + $Force, + + # Overwrites a previously installed resource with the same name and version. + [Parameter()] + [switch] + $Reinstall, + + # Suppresses progress information. + [Parameter()] + [switch] + $Quiet, + + # For modules that require a license, AcceptLicense automatically accepts the license agreement during installation. + [Parameter()] + [switch] + $AcceptLicense, + + # Returns the resource as an object to the console. + [Parameter()] + [switch] + $PassThru + ) + + begin { } + process { + foreach ($n in $Name) { + if ($pscmdlet.ShouldProcess($n)) { + + if (Find-PSResource $n) { + # Install the resource + write-verbose -message "Successfully installed $n" + } + } + } + } + end { } +} diff --git a/v3prototype/Install-PSResourceValidations.ps1 b/v3prototype/Install-PSResourceValidations.ps1 new file mode 100644 index 00000000..3c61ea81 --- /dev/null +++ b/v3prototype/Install-PSResourceValidations.ps1 @@ -0,0 +1,175 @@ +########################## +### Install-PSResource ### +########################## + +### Installing Modules ### + +# Should install the module 'TestModule' +Install-PSResource 'TestModule' + +# Should install the module 'TestModule' +Install-PSResource -name 'TestModule' + +# Should install the modules 'TestModule1', 'TestModule2', 'TestModule3' +Install-PSResource 'TestModule1', 'TestModule2', 'TestModule3' + +# Should install the latest, non-prerelease version of the module "TestModule" that is at least 1.5.0 +Install-PSResource "TestModule" -MinimumVersion "1.5.0" + +# Should install the latest, non-prerelease version of the module "TestModule" that is at most 1.5.0 +Install-PSResource "TestModule" -MaximumVersion "1.5.0" + +# Should install the latest, non-prerelease version of the module "TestModule" that is at least version 1.0.0 and at most 2.0.0 +Install-PSResource "TestModule" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" + +# Should install version 1.5.0 (non-prerelease) of the module "TestModule" +Install-PSResource "TestModule" -RequiredVersion "1.5.0" + +# Should install the latest verison of "TestModule", including prerelease versions +Install-PSResource "TestModule" -Prerelease + +# Should install "TestModule" from one of the specified repositories (based on repo priority) +Install-PSResource "TestModule" -Repository "Repository1", "Repository2" + +# Should install the module Pester +Install-PSResource -RequiredResources @{ + "Configuration" = "[1.3.1,2.0)" + "Pester" = @{ + version = "[4.4.2,4.7.0]" + repository = "https://www.powershellgallery.com" + } +} + +# Should install the module Pester +Install-PSResource -RequiredResources ConvertTo-Json ( + @{ + "Configuration" = "[1.3.1,2.0)" + "Pester" = @{ + version = "[4.4.2,4.7.0]" + repository = "https://www.powershellgallery.com" + } + } +) + +# Should install the required resources in RequiredResource.psd1 +Install-PSResource -RequiredResourcesFile 'RequiredResource.psd1' + +# Should install the required resources in RequiredResource.json +Install-PSResource -RequiredResourcesFile 'RequiredResource.json' + +# Should install the module "TestModule" to the CurrentUser scope +Install-PSResource "TestModule" -Scope "CurrentUser" + +# Should install the module "TestModule" to the AllUsers scope +Install-PSResource "TestModule" -Scope "AllUsers" + +# Should install the module "TestModule" without prompting warning message regarding installation conflicts +Install-PSResource "TestModule" -NoClobber + +# Should install the module "TestModule" without prompting message regarding publisher mismatch +Install-PSResource "TestModule" -IgnoreDifferentPublisher + +# Should install the module "TestModule" without prompting message regarding untrusted sources +Install-PSResource "TestModule" -TrustRepository + +# Should install the module "TestModule" without prompting message regarding untrusted sources +Install-PSResource "TestModule" -Force + +# Should reinstall the module "TestModule" +Install-PSResource "TestModule" -Reinstall + +#Should install the module "TestModule" without displaying progress information +Install-PSResource "TestModule" -Quiet + +#Should install the module "TestModule" and automatically accept license agreement +Install-PSResource "TestModule" -AcceptLicense + +#Should install the module "TestModule" and return the module as an object to the console +Install-PSResource "TestModule" -PassThru + + + +### Installing Scripts ### + +# Should install the script 'TestScript' +Install-PSResource 'TestScript' + +# Should install the script 'TestScript' +Install-PSResource -name 'TestScript' + +# Should install the scripts 'TestScript1', 'TestScript2', 'TestScript3' +Install-PSResource 'TestScript1', 'TestScript2', 'TestScript3' + +# Should install the latest, non-prerelease version of the script "TestScript" that is at least 1.5.0 +Install-PSResource "TestScript" -MinimumVersion "1.5.0" + +# Should install the latest, non-prerelease version of the script "TestScript" that is at most 1.5.0 +Install-PSResource "TestScript" -MaximumVersion "1.5.0" + +# Should install the latest, non-prerelease version of the script "TestScript" that is at least version 1.0.0 and at most 2.0.0 +Install-PSResource "TestScript" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" + +# Should install version 1.5.0 (non-prerelease) of the script "TestScript" +Install-PSResource "TestScript" -RequiredVersion "1.5.0" + +# Should install the latest verison of "TestScript", including prerelease versions +Install-PSResource "TestScript" -Prerelease + +# Should install "TestScript" from one of the specified repositories (based on repo priority) +Install-PSResource "TestScript" -Repository "Repository1", "Repository2" + +# Should install the script TestScript +Install-PSResource -RequiredResources @{ + "Configuration" = "[1.3.1,2.0)" + "TestScript" = @{ + version = "[4.4.2,4.7.0]" + repository = "https://www.powershellgallery.com" + } +} + +# Should install the script TestScript +Install-PSResource -RequiredResources ConvertTo-Json ( + @{ + "Configuration" = "[1.3.1,2.0)" + "TestScript" = @{ + version = "[4.4.2,4.7.0]" + repository = "https://www.powershellgallery.com" + } + } +) + +# Should install the required resources in RequiredResource.psd1 +Install-PSResource -RequiredResourcesFile 'RequiredResource.psd1' + +# Should install the required resources in RequiredResource.json +Install-PSResource -RequiredResourcesFile 'RequiredResource.json' + +# Should install the script "TestScript" to the CurrentUser scope +Install-PSResource "TestScript" -Scope "CurrentUser" + +# Should install the script "TestScript" to the AllUsers scope +Install-PSResource "TestScript" -Scope "AllUsers" + +# Should install the module "TestModule" without prompting warning message regarding installation conflicts +Install-PSResource "TestModule" -NoClobber + +# Should install the script "TestScript" without prompting message regarding publisher mismatch +Install-PSResource "TestScript" -IgnoreDifferentPublisher + +# Should install the script "TestScript" without prompting message regarding untrusted sources +Install-PSResource "TestScript" -TrustRepository + +# Should install the script "TestScript" without prompting message regarding untrusted sources +Install-PSResource "TestScript" -Force + +# Should reinstall the script "TestScript" +Install-PSResource "TestScript" -Reinstall + +#Should install the script "TestScript" without displaying progress information +Install-PSResource "TestScript" -Quiet + +#Should install the script "TestScript" and automatically accept license agreement +Install-PSResource "TestScript" -AcceptLicense + +#Should install the script "TestScript" and return the script as an object to the console +Install-PSResource "TestScript" -PassThru From e132577f96877e4579ec51b753c4c5709fcba802 Mon Sep 17 00:00:00 2001 From: Amber Erickson Date: Tue, 13 Aug 2019 14:33:21 -0700 Subject: [PATCH 04/11] Update Find-PSResource cmd and validations --- v3prototype/Find-PSResource.ps1 | 32 +- v3prototype/Find-PSResourceValidations.ps1 | 490 +++++++++++++++++++++ 2 files changed, 506 insertions(+), 16 deletions(-) create mode 100644 v3prototype/Find-PSResourceValidations.ps1 diff --git a/v3prototype/Find-PSResource.ps1 b/v3prototype/Find-PSResource.ps1 index 6ff14f50..eec944ac 100644 --- a/v3prototype/Find-PSResource.ps1 +++ b/v3prototype/Find-PSResource.ps1 @@ -7,8 +7,8 @@ # Find-Module returns an object with properties: Version, Name, Repository, Description # Find-Script returns an object with properties: Version, Name, Repository, Description -function Find-PSResource -{ + +function Find-PSResource { [OutputType([PSCustomObject[]])] [Cmdletbinding(SupportsShouldProcess = $true)] Param @@ -117,10 +117,10 @@ function Find-PSResource [switch] $IncludeDependencies, - # Returns only those modules that include specific kinds of PowerShell functionality. For example, you might only want to find modules that include DSCResource. + # Returns only those modules that include specific kinds of PowerShell functionality. For example, you might only want to find modules that include DSCResource. # The acceptable values for this parameter are as follows: - # Module: DscResource, Cmdlet, Function, RoleCapability; - # Scripts: Function, Workflow; + # Module: DscResource, Cmdlet, Function, RoleCapability; + # Scripts: Function, Workflow; # Resources that use this param: Package, Script. [Parameter(ParameterSetName = "PackageParameterSet")] [Parameter(ParameterSetName = "ScriptParameterSet")] @@ -153,30 +153,30 @@ function Find-PSResource ) - begin{ - #For each repository, if local cache does not exist then Update-PSResourceCache + begin { + # For each repository, if local cache does not exist then Update-PSResourceCache } - process{ + process { # Returning the array of resources $foundResources - foreach ($n in $name){ + foreach ($n in $name) { if ($pscmdlet.ShouldProcess($n)) { $PSResource = [PSCustomObject] @{ - Name = $Name - Version = "placeholder-for-module-version" - Type = $Type - Description = "placeholder-for-description" + Name = $Name + Version = "placeholder-for-module-version" + Type = $Type + Description = "placeholder-for-description" } - + $foundResources += $PSResource } } return $foundResources } - end{} -} \ No newline at end of file + end { } +} diff --git a/v3prototype/Find-PSResourceValidations.ps1 b/v3prototype/Find-PSResourceValidations.ps1 new file mode 100644 index 00000000..375614f1 --- /dev/null +++ b/v3prototype/Find-PSResourceValidations.ps1 @@ -0,0 +1,490 @@ +####################### +### Find-PSResource ### +####################### + +### Find command ### +# Should find the command "TestCommand" +Find-PSResource -name "TestCommand" + +# Should find the command "TestCommand" +Find-PSResource "TestCommand" + +# Should find the command "TestCommand" +Find-PSResource "TestCommand" -Type "Command" + +# Should find the command "TestCommand" +Find-PSResource "TestCommand" -Type "Command", "DscResource", "RoleCapability", "Module", "Script" + +# Should find the command "TestCommand" from the module "TestCommandModuleName" +Find-PSResource "TestCommand" -ModuleName "TestCommandModuleName" + +# Should find the command "TestCommand" from the latest, non-prerelease module "TestCommandModuleName" that has a minimum version 1.5.0 +Find-PSResource "TestCommand" -ModuleName "TestCommandModuleName" -MinimumVersion "1.5.0" + +# Should find the command "TestCommand" from the latest, non-prerelease module "TestCommandModuleName" that has a maximum version of 1.5.0 +Find-PSResource "TestCommand" -ModuleName "TestCommandModuleName" -MaximumVersion "1.5.0" + +# Should find the command "TestCommand" from the latest, non-prerelease module "TestCommandModuleName" that has a minimum version of 1.0.0 and a maximum version of 2.0.0 +Find-PSResource "TestCommand" -ModuleName "TestCommandModuleName" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" + +# Should find the command "TestCommand" from the module "TestCommandModuleName" that is exactly version 1.5.0 (non-prerelease) +Find-PSResource "TestCommand" -ModuleName "TestCommandModuleName" -RequiredVersion "1.5.0" + +# Should find the command "TestCommand" from all non-prerelease versions of the module "TestCommandModuleName" +Find-PSResource "TestCommand" -ModuleName "TestCommandModuleName" -AllVersions + +# Should find the command "TestCommand" from the latest verions of the module "TestCommandModuleName", including prerelease versions +Find-PSResource "TestCommand" -ModuleName "TestCommandModuleName" -Prerelease + +# Should find the command "TestCommand" from a resource with the tags "Tag1", "Tag2", "Tag3" +Find-PSResource "TestCommand" -Tag "Tag1", "Tag2", "Tag3" + +# Should find the command "TestCommand" from a resource that has "Test" in either the module name or description +Find-PSResource "TestCommand" -Filter "Test" + +# Should find the command "TestCommand" from one of the specified repositories +Find-PSResource "TestCommand" -Repository "Repository1", "Repository2" + +# Should NOT find the command "TestCommand" +Find-PSResource "TestCommand" -Type "TestDscResource" + + + +### Find DSC resource ### +# Should find the DSC resource "TestDscResource" +Find-PSResource -name "TestDscResource" + +# Should find the DSC resource "TestDscResource" +Find-PSResource "TestDscResource" + +# Should find the DSC resource "TestDscResource" +Find-PSResource "TestDscResource" -Type "DscResource" + +# Should find the DSC resource "TestDscResource" +Find-PSResource "TestDscResource" -Type "Command", "DscResource", "RoleCapability", "Module", "Script" + +# Should find the DSC resource "TestDscResource" that is contained within the module "TestDscResourceModuleName" +Find-PSResource "TestDscResource" -ModuleName "TestDscResourceModuleName" + +# Should find the DSC resource "TestDscResource" from the latest, non-prerelease module "TestDscResourceModuleName" that has a minimum version 1.5.0 +Find-PSResource "TestDscResource" -ModuleName "TestDscResourceModuleName" -MinimumVersion "1.5.0" + +# Should find the DSC resource "TestDscResource" from the latest, non-prerelease module "TestDscResourceModuleName" that has a maximum version of 1.5.0 +Find-PSResource "TestDscResource" -ModuleName "TestDscResourceModuleName" -MaximumVersion "1.5.0" + +# Should find the DSC resource "TestDscResource" from the latest, non-prelease module "TestDscResourceModuleName" that has a minimum version of 1.0.0 and a maximum version of 2.0.0 +Find-PSResource "TestDscResource" -ModuleName "TestDscResourceModuleName" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" + +# Should find the DSC resource "TestDscResource" from the module "TestDscResourceModuleName" that has a required version of 1.5.0 (non-prerelease) +Find-PSResource "TestDscResource" -ModuleName "TestDscResourceModuleName" -RequiredVersion "1.5.0" + +# Should find the DSC resource "TestDscResource" from all non-prerelease versions of the module "TestDscResourceModuleName" +Find-PSResource "TestDscResource" -ModuleName "TestDscResourceModuleName" -AllVersions + +# Should find the DSC resource "TestDscResource" from the latest module "TestDscResourceModuleName", including prerelease versions +Find-PSResource "TestDscResource" -ModuleName "TestDscResourceModuleName" -Prerelease + +# Should find the DSC resource "TestDscResource" from a resource with the tags "Tag1", "Tag2", "Tag3" +Find-PSResource "TestDscResource" -Tag "Tag1", "Tag2", "Tag3" + +# Should find the DSC resource "TestDscResource" from a resource that has "Test" in either the module name or description +Find-PSResource "TestDscResource" -Filter "Test" + +# Should find the DSC resource "TestDscResource" from one of the specified repositories +Find-PSResource "TestDscResource" -Repository "Repository1", "Repository2" + +# Should NOT find the DSC resource "TestDscResource" +Find-PSResource "TestDscResource" -Type "DscResource" + + + +### Find role capability ### +# Should find the role capability "TestRoleCapability" +Find-PSResource -name "TestRoleCapability" + +# Should find the role capability "TestRoleCapability" +Find-PSResource "TestRoleCapability" + +# Should find the role capability "TestRoleCapability" +Find-PSResource "TestRoleCapability" -Type "DscResource" + +# Should find the role capability "TestRoleCapability" +Find-PSResource "TestRoleCapability" -Type "Command", "DscResource", "RoleCapability", "Module", "Script" + +# Should find the role capability "TestRoleCapability" from the module +Find-PSResource "TestRoleCapability" -ModuleName "TestDscResourceModuleName" + +# Should find the role capability "TestRoleCapability" from the latest, non-prerelease module "TestDscResourceModuleName" that has a minimum version 1.5.0 +Find-PSResource "TestRoleCapability" -ModuleName "TestDscResourceModuleName" -MinimumVersion "1.5.0" + +# Should find the role capability "TestRoleCapability" from the latest, non-prerelease modules with name "TestDscResourceModuleName" that has a maximum version of 1.5.0 +Find-PSResource "TestRoleCapability" -ModuleName "TestDscResourceModuleName" -MaximumVersion "1.5.0" + +# Should find the command "TestRoleCapability" from the latest, non-prerelease module with name "TestDscResourceModuleName" that has a minimum version of 1.0.0 and a maximum version of 2.0.0 +Find-PSResource "TestRoleCapability" -ModuleName "TestDscResourceModuleName" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" + +# Should find the role capability "TestRoleCapability" from the module "TestDscResourceModuleName" that has a required version of 1.5.0 (non-prerelease) +Find-PSResource "TestRoleCapability" -ModuleName "TestDscResourceModuleName" -RequiredVersion "1.5.0" + +# Should find the role capability "TestRoleCapability" from all non-prerelease versions of the module "TestDscResourceModuleName" +Find-PSResource "TestRoleCapability" -ModuleName "TestDscResourceModuleName" -AllVersions + +# Should find the role capability "TestRoleCapability" from the module "TestDscresourceModuleName", including prerelease versions +Find-PSResource "TestRoleCapability" -ModuleName "TestDscResourceModuleName" -Prerelease + +# Should find the role capability "TestRoleCapability" from a resource with the tags "Tag1", "Tag2", "Tag3" +Find-PSResource "TestRoleCapability" -Tag "Tag1", "Tag2", "Tag3" + +# Should find the role capability "TestRoleCapability" from a resource that has "Test" in either the module name or description +Find-PSResource "TestRoleCapability" -Filter "Test" + +# Should find the role capability "TestRoleCapability" from one of the specified repositories +Find-PSResource "TestRoleCapability" -Repository "Repository1", "Repository2" + +# Should NOT find the role capability "TestRoleCapability" +Find-PSResource "TestRoleCapability" -Type "TestDscResource" + + + +### Find module ### +# Should find the module "TestModule" +Find-PSResource -name "TestModule" + +# Should find the module "TestModule" +Find-PSResource "TestModule" + +# Should find the module "TestModule" +Find-PSResource "TestModule" -Type "Module" + +# Should find the module "TestModule" +Find-PSResource "TestModule" -Type "Command", "DscResource", "RoleCapability", "Module", "Script" + +# Should find the non-prerelase module "TestModule" that has a minimum version of 1.5.0 +Find-PSResource "TestModule" -MinimumVersion "1.5.0" + +# Should find the non-prerelease module "TestModule" that has a maximum version of 1.5.0 +Find-PSResource "TestModule" -MaximumVersion "1.5.0" + +# Should find the non-prerelease module "TestModule" that has a minimum version of 1.0.0 and a maximum version of 1.5.0 +Find-PSResource "TestModule" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" + +# Should find the latest, non-prerelease scripts "TestModule" that is exactly version 1.5.0 +Find-PSResource "TestModule" -RequiredVersion "1.5.0" + +# Should find all versions of all non-prerelease versions of the module "TestModule" +Find-PSResource "TestModule" -AllVersions + +# Should find the lastest, non-prerelease version of the module "TestModule", including prerelease versions +Find-PSResource "TestModule" -Prerelease + +# Should find the module "TestModule" with the tags "Tag1", "Tag2", "Tag3" +Find-PSResource "TestModule" -Tag "Tag1", "Tag2", "Tag3" + +# Should find the module "TestModule" that has "Test" in either the module name or description +Find-PSResource "TestModule" -Filter "Test" + +# Should find the module "TestModule" from all of the specified repositories +Find-PSResource "TestModule" -Repository "Repository1", "Repository2" + +# Should find the module "TestModule" and all modules that are dependent upon "TestModule" +Find-PSResource "TestModule" -IncludeDependencies + +# Should find the module "TestModule" that has DSC resources +Find-PSResource "TestModule" -Includes 'DscResource' + +# Should find the module "TestModule" that has DSC resources named "TestDscResource" +Find-PSResource "TestModule" -DSCResource "TestDscResource" + +# Should find the module "TestModule" that has a role capacity named "TestDscResource" +Find-PSResource "TestModule" -RoleCapability "TestRoleCapability" + +# Should find the module "TestModule" that has a command named "Test-Command" +Find-PSResource "TestModule" -Command "Test-Command" + + + +### Find Script ### +# Should find the script named "TestScript" +Find-PSResource -name "TestScript" + +# Should find the script named "TestScript" +Find-PSResource "TestScript" + +# Should find the script named "TestScript" +Find-PSResource "TestScript" -Type "Script" + +# Should find the script named "TestScript" +Find-PSResource "TestScript" -Type "Command", "DscResource", "RoleCapability", "Module", "Script" + +# Should find the latest, non-prerelease script "TestScript" that has a minimum version of 1.5.0 +Find-PSResource "TestScript" -MinimumVersion "1.5.0" + +# Should find the latest, non-prerelease script "TestScript" that have a maximum version of 1.5.0 +Find-PSResource "TestScript" -MaximumVersion "1.5.0" + +# Should find the latest, non-prerelease script "TestScript" that has a minimum version of 1.0.0 and a maximum version of 1.5.0 +Find-PSResource "TestScript" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" + +# Should find the latest, non-prerelease scripts "TestScript" that is exactly version 1.5.0 +Find-PSResource "TestScript" -RequiredVersion "1.5.0" + +# Should find all versions of all scripts named "TestScript", not including prerelease versions +Find-PSResource "TestScript" -AllVersions + +# Should find the script "TestScript", including prerelease versions +Find-PSResource "TestScript" -AllowPrerelease + +# Should find the script "TestScript" with the tags "Tag1", "Tag2", "Tag3" +Find-PSResource "TestScript" -Tag "Tag1", "Tag2", "Tag3" + +# Should find the script "TestScript" that has "Test" in either the script name or description +Find-PSResource "TestScript" -Filter "Test" + +# Should find the script "TestScript" from all of the specified repositories +Find-PSResource "TestScript" -Repository "Repository1", "Repository2" + +# Should find the script "TestScript" and all modules that are dependent upon "TestScript" +Find-PSResource "TestScript" -IncludeDependencies + +# Should find the script "TestScript" that has a function named "TestFunction" +Find-PSResource "TestScript" -Includes 'TestFunction' + +# Should find the script "TestScript" that has a command named "Test-Command" +Find-PSResource "TestScript" -Command "Test-Command" + + + +### Find multiple resources ### +# Should find the resources "TestResource1", "TestResource2", "TestResource3" +Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" + +# Should find the resource "TestResource1", "TestResource2", "TestResource3" +Find-PSResource "TestResource1", "TestResource2", "TestResource3" + +# Should find the resources "TestResource1", "TestResource2", "TestResource3" +Find-PSResource "TestResource1", "TestResource2", "TestResource3" -Type "Module" + +# Should find the "TestResource1", "TestResource2", "TestResource3" +Find-PSResource "TestResource1", "TestResource2", "TestResource3" -Type "Command", "DscResource", "RoleCapability", "Module", "Script" + +# Should find the latest, non-prerelease modules "TestResource1", "TestResource2", "TestResource3" that have a minimum version of 1.5.0 +Find-PSResource "TestResource1", "TestResource2", "TestResource3" -MinimumVersion "1.5.0" + +# Should find the latest, non-prerelease modules "TestResource1", "TestResource2", "TestResource3" that have a maximum version of 1.5.0 +Find-PSResource "TestResource1", "TestResource2", "TestResource3" -MaximumVersion "1.5.0" + +# Should find the latest, non-prerelease modules "TestResource1", "TestResource2", "TestResource3" that have a minimum version of 1.0.0 and a maximum version of 1.5.0 +Find-PSResource "TestResource1", "TestResource2", "TestResource3" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" + +# Should find the modules "TestResource1", "TestResource2", "TestResource3" that are exactly version 1.5.0 +Find-PSResource "TestResource1", "TestResource2", "TestResource3" -RequiredVersion "1.5.0" + +# Should find all non-prerelease versions of the modules "TestResource1", "TestResource2", "TestResource3", not including prerelease versions +Find-PSResource "TestResource1", "TestResource2", "TestResource3" -AllVersions + +# Should find the modules "TestResource1", "TestResource2", "TestResource3", including prerelease versions +Find-PSResource "TestResource1", "TestResource2", "TestResource3" -Prerelease + +# Should find the modules "TestResource1", "TestResource2", "TestResource3" with the tags "Tag1", "Tag2", "Tag3" +Find-PSResource "TestResource1", "TestResource2", "TestResource3" -Tag "Tag1", "Tag2", "Tag3" + +# Should find the modules "TestResource1", "TestResource2", "TestResource3" that have "Test" in either the module name or description +Find-PSResource "TestResource1", "TestResource2", "TestResource3" -Filter "Test" + +# Should find the modules "TestResource1", "TestResource2", "TestResource3" from all of the specified repositories +Find-PSResource "TestResource1", "TestResource2", "TestResource3" -Repository "Repository1", "Repository2" + +# Should find the modules "TestResource1", "TestResource2", "TestResource3" and all modules that are dependent upon "TestResource1", "TestResource2", "TestResource3" +Find-PSResource "TestResource1", "TestResource2", "TestResource3" -IncludeDependencies + +# Should find the modules "TestResource1", "TestResource2", "TestResource3" that have DSC resources +Find-PSResource "TestResource1", "TestResource2", "TestResource3" -Includes 'DscResource' + +# Should find the modules "TestResource1", "TestResource2", "TestResource3" that have DSC resources named "TestDscResource" +Find-PSResource "TestResource1", "TestResource2", "TestResource3" -DSCResource "TestDscResource" + +# Should find all the modules named "TestResource1", "TestResource2", "TestResource3" that have a role capacity named "TestRoleCapacity" +Find-PSResource "TestResource1", "TestResource2", "TestResource3" -RoleCapability "TestRoleCapability" + +# Should find all the modules named "TestResource1", "TestResource2", "TestResource3" that have a command named "Test-Command" +Find-PSResource "TestResource1", "TestResource2", "TestResource3" -Command "Test-Command" + + + + + +########################## +### Install-PSResource ### +########################## + +### Installing Modules ### + +# Should install the module 'TestModule' +Install-PSResource 'TestModule' + +# Should install the module 'TestModule' +Install-PSResource -name 'TestModule' + +# Should install the modules 'TestModule1', 'TestModule2', 'TestModule3' +Install-PSResource 'TestModule1', 'TestModule2', 'TestModule3' + +# Should install the latest, non-prerelease version of the module "TestModule" that is at least 1.5.0 +Install-PSResource "TestModule" -MinimumVersion "1.5.0" + +# Should install the latest, non-prerelease version of the module "TestModule" that is at most 1.5.0 +Install-PSResource "TestModule" -MaximumVersion "1.5.0" + +# Should install the latest, non-prerelease version of the module "TestModule" that is at least version 1.0.0 and at most 2.0.0 +Install-PSResource "TestModule" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" + +# Should install version 1.5.0 (non-prerelease) of the module "TestModule" +Install-PSResource "TestModule" -RequiredVersion "1.5.0" + +# Should install the latest verison of "TestModule", including prerelease versions +Install-PSResource "TestModule" -Prerelease + +# Should install "TestModule" from one of the specified repositories (based on repo priority) +Install-PSResource "TestModule" -Repository "Repository1", "Repository2" + +# Should install the module Pester +Install-PSResource -RequiredResources @{ + "Configuration" = "[1.3.1,2.0)" + "Pester" = @{ + version = "[4.4.2,4.7.0]" + repository = "https://www.powershellgallery.com" + } +} + +# Should install the module Pester +Install-PSResource -RequiredResources ConvertTo-Json ( + @{ + "Configuration" = "[1.3.1,2.0)" + "Pester" = @{ + version = "[4.4.2,4.7.0]" + repository = "https://www.powershellgallery.com" + } + } +) + +# Should install the required resources in RequiredResource.psd1 +Install-PSResource -RequiredResourcesFile 'RequiredResource.psd1' + +# Should install the required resources in RequiredResource.json +Install-PSResource -RequiredResourcesFile 'RequiredResource.json' + +# Should install the module "TestModule" to the CurrentUser scope +Install-PSResource "TestModule" -Scope "CurrentUser" + +# Should install the module "TestModule" to the AllUsers scope +Install-PSResource "TestModule" -Scope "AllUsers" + +# Should install the module "TestModule" without prompting warning message regarding installation conflicts +Install-PSResource "TestModule" -NoClobber + +# Should install the module "TestModule" without prompting message regarding publisher mismatch +Install-PSResource "TestModule" -IgnoreDifferentPublisher + +# Should install the module "TestModule" without prompting message regarding untrusted sources +Install-PSResource "TestModule" -TrustRepository + +# Should install the module "TestModule" without prompting message regarding untrusted sources +Install-PSResource "TestModule" -Force + +# Should reinstall the module "TestModule" +Install-PSResource "TestModule" -Reinstall + +#Should install the module "TestModule" without displaying progress information +Install-PSResource "TestModule" -Quiet + +#Should install the module "TestModule" and automatically accept license agreement +Install-PSResource "TestModule" -AcceptLicense + +#Should install the module "TestModule" and return the module as an object to the console +Install-PSResource "TestModule" -PassThru + + + +### Installing Scripts ### ############ + +# Should install the script 'TestScript' +Install-PSResource 'TestScript' + +# Should install the script 'TestScript' +Install-PSResource -name 'TestScript' + +# Should install the scripts 'TestScript1', 'TestScript2', 'TestScript3' +Install-PSResource 'TestScript1', 'TestScript2', 'TestScript3' + +# Should install the latest, non-prerelease version of the script "TestScript" that is at least 1.5.0 +Install-PSResource "TestScript" -MinimumVersion "1.5.0" + +# Should install the latest, non-prerelease version of the script "TestScript" that is at most 1.5.0 +Install-PSResource "TestScript" -MaximumVersion "1.5.0" + +# Should install the latest, non-prerelease version of the script "TestScript" that is at least version 1.0.0 and at most 2.0.0 +Install-PSResource "TestScript" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" + +# Should install version 1.5.0 (non-prerelease) of the script "TestScript" +Install-PSResource "TestScript" -RequiredVersion "1.5.0" + +# Should install the latest verison of "TestScript", including prerelease versions +Install-PSResource "TestScript" -Prerelease + +# Should install "TestScript" from one of the specified repositories (based on repo priority) +Install-PSResource "TestScript" -Repository "Repository1", "Repository2" + +# Should install the script TestScript +Install-PSResource -RequiredResources @{ + "Configuration" = "[1.3.1,2.0)" + "TestScript" = @{ + version = "[4.4.2,4.7.0]" + repository = "https://www.powershellgallery.com" + } +} + +# Should install the script TestScript +Install-PSResource -RequiredResources ConvertTo-Json ( + @{ + "Configuration" = "[1.3.1,2.0)" + "TestScript" = @{ + version = "[4.4.2,4.7.0]" + repository = "https://www.powershellgallery.com" + } + } +) + +# Should install the required resources in RequiredResource.psd1 +Install-PSResource -RequiredResourcesFile 'RequiredResource.psd1' + +# Should install the required resources in RequiredResource.json +Install-PSResource -RequiredResourcesFile 'RequiredResource.json' + +# Should install the script "TestScript" to the CurrentUser scope +Install-PSResource "TestScript" -Scope "CurrentUser" + +# Should install the script "TestScript" to the AllUsers scope +Install-PSResource "TestScript" -Scope "AllUsers" + +# Should install the module "TestModule" without prompting warning message regarding installation conflicts +Install-PSResource "TestModule" -NoClobber + +# Should install the script "TestScript" without prompting message regarding publisher mismatch +Install-PSResource "TestScript" -IgnoreDifferentPublisher + +# Should install the script "TestScript" without prompting message regarding untrusted sources +Install-PSResource "TestScript" -TrustRepository + +# Should install the script "TestScript" without prompting message regarding untrusted sources +Install-PSResource "TestScript" -Force + +# Should reinstall the script "TestScript" +Install-PSResource "TestScript" -Reinstall + +#Should install the script "TestScript" without displaying progress information +Install-PSResource "TestScript" -Quiet + +#Should install the script "TestScript" and automatically accept license agreement +Install-PSResource "TestScript" -AcceptLicense + +#Should install the script "TestScript" and return the script as an object to the console +Install-PSResource "TestScript" -PassThru From c29cfc6fb187745aadd19b2fd64be43129f269ab Mon Sep 17 00:00:00 2001 From: Amber Erickson Date: Tue, 13 Aug 2019 17:30:31 -0700 Subject: [PATCH 05/11] Add Save-PSResource cmd and validations --- v3prototype/Save-PSResource.ps1 | 164 +++++++++++++++++++++ v3prototype/Save-PSResourceValidations.ps1 | 152 +++++++++++++++++++ 2 files changed, 316 insertions(+) create mode 100644 v3prototype/Save-PSResource.ps1 create mode 100644 v3prototype/Save-PSResourceValidations.ps1 diff --git a/v3prototype/Save-PSResource.ps1 b/v3prototype/Save-PSResource.ps1 new file mode 100644 index 00000000..a5ec7c26 --- /dev/null +++ b/v3prototype/Save-PSResource.ps1 @@ -0,0 +1,164 @@ +# Saving resources +function Save-PSResource { + [OutputType([void])] + [cmdletbinding(SupportsShouldProcess = $true)] + Param + ( + # Specifies the exact names of resources to save from a repository. + [Parameter(Mandatory = $true, + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, + Position = 0, + ParameterSetName = 'NameAndPathParameterSet')] + [Parameter(Mandatory = $true, + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, + Position = 0, + ParameterSetName = 'NameAndLiteralPathParameterSet')] + [ValidateNotNullOrEmpty()] + [string[]] + $Name, + + # Specifies the type of the resource being saved. + [Parameter(ParameterSetName = 'NameAndPathParameterSet')] + [Parameter(ParameterSetName = 'NameAndLiteralPathParameterSet')] + [ValidateSet('Module', 'Script', 'Library')] + [string[]] + $Type, + + # Used for pipeline input. + [Parameter(Mandatory = $true, + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, + Position = 0, + ParameterSetName = 'InputObjectAndPathParameterSet')] + [Parameter(Mandatory = $true, + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, + Position = 0, + ParameterSetName = 'InputObjectAndLiteralPathParameterSet')] + [ValidateNotNull()] + [PSCustomObject[]] + $InputObject, + + # Specifies the minimum version of the resource to be saved (cannot use this parameter with the RequiredVersion parameter). + [Parameter(ValueFromPipelineByPropertyName = $true, + ParameterSetName = 'NameAndPathParameterSet')] + [Parameter(ValueFromPipelineByPropertyName = $true, + ParameterSetName = 'NameAndLiteralPathParameterSet')] + [ValidateNotNull()] + [string] + $MinimumVersion, + + # Specifies the maximum version of the resource to include to be saved (cannot use this parameter with the RequiredVersion parameter). + [Parameter(ValueFromPipelineByPropertyName = $true, + ParameterSetName = 'NameAndPathParameterSet')] + [Parameter(ValueFromPipelineByPropertyName = $true, + ParameterSetName = 'NameAndLiteralPathParameterSet')] + [ValidateNotNull()] + [string] + $MaximumVersion, + + # Specifies the required version of the resource to include to be installed (cannot use this parameter with the MinimumVersion or MaximumVersion parameters). + [Parameter(ValueFromPipelineByPropertyName = $true, + ParameterSetName = 'NameAndPathParameterSet')] + [Parameter(ValueFromPipelineByPropertyName = $true, + ParameterSetName = 'NameAndLiteralPathParameterSet')] + [ValidateNotNull()] + [string] + $RequiredVersion, + + # Specifies the repository to search within (default is all repositories). + [Parameter(ValueFromPipelineByPropertyName = $true, + ParameterSetName = 'NameAndPathParameterSet')] + [Parameter(ValueFromPipelineByPropertyName = $true, + ParameterSetName = 'NameAndLiteralPathParameterSet')] + [ValidateNotNullOrEmpty()] + [string[]] + $Repository, + + # Specifies the location on the local computer to store a saved resource. Accepts wildcard characters. + [Parameter(Mandatory = $true, + Position = 1, + ValueFromPipelineByPropertyName = $true, + ParameterSetName = 'NameAndPathParameterSet')] + [Parameter(Mandatory = $true, + Position = 1, + ValueFromPipelineByPropertyName = $true, + ParameterSetName = 'InputObjectAndPathParameterSet')] + [string] + $Path, + + # Specifies a path to one or more locations. + # The value of the LiteralPath parameter is used exactly as entered. No characters are interpreted as wildcards. + # If the path includes escape characters, enclose them in single quotation marks. + # PowerShell does not interpret any characters enclosed in single quotation marks as escape sequences. + [Parameter(Mandatory = $true, + ValueFromPipelineByPropertyName = $true, + ParameterSetName = 'NameAndLiteralPathParameterSet')] + [Parameter(Mandatory = $true, + ValueFromPipelineByPropertyName = $true, + ParameterSetName = 'InputObjectAndLiteralPathParameterSet')] + [Alias('PSPath')] + [string] + $LiteralPath, + + # Specifies a proxy server for the request, rather than connecting directly to an internet resource. + [Parameter(ValueFromPipelineByPropertyName = $true)] + [ValidateNotNullOrEmpty()] + [Uri] + $Proxy, + + # Specifies a user account that has permission to use the proxy server specified by the Proxy parameter. + [Parameter(ValueFromPipelineByPropertyName = $true)] + [PSCredential] + $ProxyCredential, + + # Specifies a user account that has permission to save a resource from a specific repository. + [Parameter(ValueFromPipelineByPropertyName = $true)] + [PSCredential] + $Credential, + + # Saves a resource without asking for user confirmation. + [Parameter()] + [switch] + $Force, + + # Allows you to save a resource marked as a prerelease. + [Parameter(ParameterSetName = 'NameAndPathParameterSet')] + [Parameter(ParameterSetName = 'NameAndLiteralPathParameterSet')] + [switch] + $Prerelease, + + # Automatically accept the license agreement if the resoruce requires it. + [Parameter()] + [switch] + $AcceptLicense, + + # Will save the resource as a nupkg (if it was originally a nupkg) instead of expanding it into a folder. + [Parameter()] + [switch] + $AsNupkg, + + # Will explicitly retain the runtimes directory hierarchy within the nupkg to the root of the destination. + [Parameter()] + [switch] + $IncludeAllRuntimes + ) + + + begin { } + process { + foreach ($n in $Name) { + if ($pscmdlet.ShouldProcess($n)) { + + if (Find-PSResource $n) { + + # Save the resource-- use install logic + write-verbose -message "Successfully saved $n" + } + } + } + } + end { } +} diff --git a/v3prototype/Save-PSResourceValidations.ps1 b/v3prototype/Save-PSResourceValidations.ps1 new file mode 100644 index 00000000..6aa687dd --- /dev/null +++ b/v3prototype/Save-PSResourceValidations.ps1 @@ -0,0 +1,152 @@ +####################### +### Save-PSResource ### +####################### +### Saving Modules ### +# Should save the module 'TestModule' +Save-PSResource 'TestModule' + +# Should save the module 'TestModule' +Save-PSResource -name 'TestModule' + +# Should save the module 'TestModule' +Save-PSResource 'TestModule' -Type 'Module' + +# Should save the module 'TestModule' +Save-PSResource 'TestModule' -Type 'Module', 'Script', 'Library' + +# Should save the modules 'TestModule1', 'TestModule2', 'TestModule3' +Save-PSResource 'TestModule1', 'TestModule2', 'TestModule3' + +# Should save the latest, non-prerelease version of the module 'TestModule' that is at least 1.5.0 +Save-PSResource 'TestModule' -MinimumVersion '1.5.0' + +# Should save the latest, non-prerelease version of the module 'TestModule' that is at most 1.5.0 +Save-PSResource 'TestModule' -MaximumVersion '1.5.0' + +# Should save the latest, non-prerelease version of the module 'TestModule' that is at least version 1.0.0 and at most 2.0.0 +Save-PSResource 'TestModule' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' + +# Should save version 1.5.0 (non-prerelease) of the module 'TestModule' +Save-PSResource 'TestModule' -RequiredVersion '1.5.0' + +# Should save the latest verison of 'TestModule', including prerelease versions +Save-PSResource 'TestModule' -Prerelease + +# Should save 'TestModule' from one of the specified repositories (based on repo priority) +Save-PSResource 'TestModule' -Repository 'Repository1', 'Repository2' + +# Should save the module 'TestModule' to the specified directory +Save-PSResource 'TestModule' -Path '.\*\somepath' + +# Should save the module 'TestModule' to the specified directory +Save-PSResource 'TestModule' -LiteralPath '.' + +# Should save the module 'TestModule' without prompting user for confirmation +Save-PSResource 'TestModule' -Force + +#Should save the module 'TestModule' and automatically accept license agreement +Save-PSResource 'TestModule' -AcceptLicense + +#Should save the module 'TestModule' from the input object +Find-PSResource 'TestModule' | Save-PSresource + + + +### Saving Scripts ### +# Should save the script 'TestScript' +Save-PSResource 'TestScript' + +# Should save the script 'TestScript' +Save-PSResource -name 'TestScript' + +# Should save the module 'TestScript' +Save-PSResource 'TestScript' -Type 'Script' + +# Should save the module 'TestScript' +Save-PSResource 'TestScript' -Type 'Module', 'Script', 'Library' + +# Should save the scripts 'TestScript1', 'TestScript2', 'TestScript3' +Save-PSResource 'TestScript1', 'TestScript2', 'TestScript3' + +# Should save the latest, non-prerelease version of the script 'TestScript' that is at least 1.5.0 +Save-PSResource 'TestScript' -MinimumVersion '1.5.0' + +# Should save the latest, non-prerelease version of the script 'TestScript' that is at most 1.5.0 +Save-PSResource 'TestScript' -MaximumVersion '1.5.0' + +# Should save the latest, non-prerelease version of the script 'TestScript' that is at least version 1.0.0 and at most 2.0.0 +Save-PSResource 'TestScript' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' + +# Should save version 1.5.0 (non-prerelease) of the script 'TestScript' +Save-PSResource 'TestScript' -RequiredVersion '1.5.0' + +# Should save the latest verison of 'TestScript', including prerelease versions +Save-PSResource 'TestScript' -Prerelease + +# Should save 'TestScript' from one of the specified repositories (based on repo priority) +Save-PSResource 'TestScript' -Repository 'Repository1', 'Repository2' + +# Should save the script 'TestScript' to the specified directory +Save-PSResource 'TestModule' -Path '.\*\somepath' + +# Should save the script 'TestScript' to the specified directory +Save-PSResource 'TestModule' -LiteralPath '.' + +# Should save the script 'TestScript' without prompting message regarding untrusted sources +Save-PSResource 'TestScript' -Force + +#Should save the script 'TestScript' and automatically accept license agreement +Save-PSResource 'TestScript' -AcceptLicense + +#Should save the script 'TestScript' from the input object +Find-PSResource 'TestScript' | Save-PSresource + + +### Saving Nupkgs ### +# Should save the nupkg 'TestNupkg' +Save-PSResource 'TestNupkg' + +# Should save the nupkg 'TestNupkg' +Save-PSResource 'TestNupkg' -Type 'Library' + +# Should save the nupkg 'TestNupkg' +Save-PSResource 'TestNupkg' -Type 'Module', 'Script', 'Library' + +# Should save the nupkgs 'TestNupkg1', 'TestNupkg2', 'TestNupkg3' +Save-PSResource 'TestNupkg1', 'TestNupkg2', 'TestNupkg3' + +# Should save the latest, non-prerelease version of the nupkg 'TestNupkg' that is at least 1.5.0 +Save-PSResource 'TestNupkg' -MinimumVersion '1.5.0' + +# Should save the latest, non-prerelease version of the nupkg 'TestNupkg' that is at most 1.5.0 +Save-PSResource 'TestNupkg' -MaximumVersion '1.5.0' + +# Should save the latest, non-prerelease version of the nupkg 'TestNupkg' that is at least version 1.0.0 and at most 2.0.0 +Save-PSResource 'TestNupkg' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' + +# Should save version 1.5.0 (non-prerelease) of the nupkg 'TestNupkg' +Save-PSResource 'TestNupkg' -RequiredVersion '1.5.0' + +# Should save the latest verison of 'TestNupkg', including prerelease versions +Save-PSResource 'TestNupkg' -Prerelease + +# Should save the nupkg 'TestNupkg' from one of the specified repositories (based on repo priority) +Save-PSResource 'TestNupkg' -Repository 'Repository1', 'Repository2' + +# Should save the script 'TestScript' to the specified directory +Save-PSResource 'TestModule' -Path '.\*\somepath' + +# Should save the script 'TestScript' to the specified directory +Save-PSResource 'TestModule' -LiteralPath '.' + +# Should save the nupkg 'TestNupkg' without prompting user for confirmation +Save-PSResource 'TestNupkg' -Force + +#Should save the nupkg 'TestNupkg' and automatically accept license agreement +Save-PSResource 'TestNupkg' -AcceptLicense + +#Should save the nupkg 'TestNupkg' as a nupkg (if it was originally nupkg) instead of expanding it into a folder +Save-PSResource 'TestNupkg' -AsNupkg + +#Should save the nupkg 'TestNupkg' and retain the runtimes directory hierarchy within the nupkg to the root of the destination +Save-PSResource 'TestNupkg' -IncludeAllRuntimes From 93863763a79a3e4a06bea2f218190f374966073f Mon Sep 17 00:00:00 2001 From: Amber Erickson Date: Tue, 13 Aug 2019 17:31:37 -0700 Subject: [PATCH 06/11] Update syntax --- v3prototype/Find-PSResource.ps1 | 2 +- v3prototype/Find-PSResourceValidations.ps1 | 548 +++++++++--------- v3prototype/Install-PSResource.ps1 | 2 +- v3prototype/Install-PSResourceValidations.ps1 | 160 ++--- v3prototype/PSResourceValidation.ps1 | 403 +++++++------ v3prototype/RepositoryValidations.ps1 | 100 ++-- 6 files changed, 600 insertions(+), 615 deletions(-) diff --git a/v3prototype/Find-PSResource.ps1 b/v3prototype/Find-PSResource.ps1 index eec944ac..e3c24503 100644 --- a/v3prototype/Find-PSResource.ps1 +++ b/v3prototype/Find-PSResource.ps1 @@ -103,7 +103,7 @@ function Find-PSResource { [string[]] $Repository, - # Specifies a user account that has rights to install a module for a specified package provider or source. + # Specifies a user account that has rights to find a resource from a specific repository. # Resources that use this param: Package, Script. [Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = "PackageParameterSet")] [Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = "ScriptParameterSet")] diff --git a/v3prototype/Find-PSResourceValidations.ps1 b/v3prototype/Find-PSResourceValidations.ps1 index 375614f1..6f6e198e 100644 --- a/v3prototype/Find-PSResourceValidations.ps1 +++ b/v3prototype/Find-PSResourceValidations.ps1 @@ -3,311 +3,311 @@ ####################### ### Find command ### -# Should find the command "TestCommand" -Find-PSResource -name "TestCommand" +# Should find the command 'TestCommand' +Find-PSResource -name 'TestCommand' -# Should find the command "TestCommand" -Find-PSResource "TestCommand" +# Should find the command 'TestCommand' +Find-PSResource 'TestCommand' -# Should find the command "TestCommand" -Find-PSResource "TestCommand" -Type "Command" +# Should find the command 'TestCommand' +Find-PSResource 'TestCommand' -Type 'Command' -# Should find the command "TestCommand" -Find-PSResource "TestCommand" -Type "Command", "DscResource", "RoleCapability", "Module", "Script" +# Should find the command 'TestCommand' +Find-PSResource 'TestCommand' -Type 'Command', 'DscResource', 'RoleCapability', 'Module', 'Script' -# Should find the command "TestCommand" from the module "TestCommandModuleName" -Find-PSResource "TestCommand" -ModuleName "TestCommandModuleName" +# Should find the command 'TestCommand' from the module 'TestCommandModuleName' +Find-PSResource 'TestCommand' -ModuleName 'TestCommandModuleName' -# Should find the command "TestCommand" from the latest, non-prerelease module "TestCommandModuleName" that has a minimum version 1.5.0 -Find-PSResource "TestCommand" -ModuleName "TestCommandModuleName" -MinimumVersion "1.5.0" +# Should find the command 'TestCommand' from the latest, non-prerelease module 'TestCommandModuleName' that has a minimum version 1.5.0 +Find-PSResource 'TestCommand' -ModuleName 'TestCommandModuleName' -MinimumVersion '1.5.0' -# Should find the command "TestCommand" from the latest, non-prerelease module "TestCommandModuleName" that has a maximum version of 1.5.0 -Find-PSResource "TestCommand" -ModuleName "TestCommandModuleName" -MaximumVersion "1.5.0" +# Should find the command 'TestCommand' from the latest, non-prerelease module 'TestCommandModuleName' that has a maximum version of 1.5.0 +Find-PSResource 'TestCommand' -ModuleName 'TestCommandModuleName' -MaximumVersion '1.5.0' -# Should find the command "TestCommand" from the latest, non-prerelease module "TestCommandModuleName" that has a minimum version of 1.0.0 and a maximum version of 2.0.0 -Find-PSResource "TestCommand" -ModuleName "TestCommandModuleName" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" +# Should find the command 'TestCommand' from the latest, non-prerelease module 'TestCommandModuleName' that has a minimum version of 1.0.0 and a maximum version of 2.0.0 +Find-PSResource 'TestCommand' -ModuleName 'TestCommandModuleName' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' -# Should find the command "TestCommand" from the module "TestCommandModuleName" that is exactly version 1.5.0 (non-prerelease) -Find-PSResource "TestCommand" -ModuleName "TestCommandModuleName" -RequiredVersion "1.5.0" +# Should find the command 'TestCommand' from the module 'TestCommandModuleName' that is exactly version 1.5.0 (non-prerelease) +Find-PSResource 'TestCommand' -ModuleName 'TestCommandModuleName' -RequiredVersion '1.5.0' -# Should find the command "TestCommand" from all non-prerelease versions of the module "TestCommandModuleName" -Find-PSResource "TestCommand" -ModuleName "TestCommandModuleName" -AllVersions +# Should find the command 'TestCommand' from all non-prerelease versions of the module 'TestCommandModuleName' +Find-PSResource 'TestCommand' -ModuleName 'TestCommandModuleName' -AllVersions -# Should find the command "TestCommand" from the latest verions of the module "TestCommandModuleName", including prerelease versions -Find-PSResource "TestCommand" -ModuleName "TestCommandModuleName" -Prerelease +# Should find the command 'TestCommand' from the latest verions of the module 'TestCommandModuleName', including prerelease versions +Find-PSResource 'TestCommand' -ModuleName 'TestCommandModuleName' -Prerelease -# Should find the command "TestCommand" from a resource with the tags "Tag1", "Tag2", "Tag3" -Find-PSResource "TestCommand" -Tag "Tag1", "Tag2", "Tag3" +# Should find the command 'TestCommand' from a resource with the tags 'Tag1', 'Tag2', 'Tag3' +Find-PSResource 'TestCommand' -Tag 'Tag1', 'Tag2', 'Tag3' -# Should find the command "TestCommand" from a resource that has "Test" in either the module name or description -Find-PSResource "TestCommand" -Filter "Test" +# Should find the command 'TestCommand' from a resource that has 'Test' in either the module name or description +Find-PSResource 'TestCommand' -Filter 'Test' -# Should find the command "TestCommand" from one of the specified repositories -Find-PSResource "TestCommand" -Repository "Repository1", "Repository2" +# Should find the command 'TestCommand' from one of the specified repositories +Find-PSResource 'TestCommand' -Repository 'Repository1', 'Repository2' -# Should NOT find the command "TestCommand" -Find-PSResource "TestCommand" -Type "TestDscResource" +# Should NOT find the command 'TestCommand' +Find-PSResource 'TestCommand' -Type 'TestDscResource' ### Find DSC resource ### -# Should find the DSC resource "TestDscResource" -Find-PSResource -name "TestDscResource" +# Should find the DSC resource 'TestDscResource' +Find-PSResource -name 'TestDscResource' -# Should find the DSC resource "TestDscResource" -Find-PSResource "TestDscResource" +# Should find the DSC resource 'TestDscResource' +Find-PSResource 'TestDscResource' -# Should find the DSC resource "TestDscResource" -Find-PSResource "TestDscResource" -Type "DscResource" +# Should find the DSC resource 'TestDscResource' +Find-PSResource 'TestDscResource' -Type 'DscResource' -# Should find the DSC resource "TestDscResource" -Find-PSResource "TestDscResource" -Type "Command", "DscResource", "RoleCapability", "Module", "Script" +# Should find the DSC resource 'TestDscResource' +Find-PSResource 'TestDscResource' -Type 'Command', 'DscResource', 'RoleCapability', 'Module', 'Script' -# Should find the DSC resource "TestDscResource" that is contained within the module "TestDscResourceModuleName" -Find-PSResource "TestDscResource" -ModuleName "TestDscResourceModuleName" +# Should find the DSC resource 'TestDscResource' that is contained within the module 'TestDscResourceModuleName' +Find-PSResource 'TestDscResource' -ModuleName 'TestDscResourceModuleName' -# Should find the DSC resource "TestDscResource" from the latest, non-prerelease module "TestDscResourceModuleName" that has a minimum version 1.5.0 -Find-PSResource "TestDscResource" -ModuleName "TestDscResourceModuleName" -MinimumVersion "1.5.0" +# Should find the DSC resource 'TestDscResource' from the latest, non-prerelease module 'TestDscResourceModuleName' that has a minimum version 1.5.0 +Find-PSResource 'TestDscResource' -ModuleName 'TestDscResourceModuleName' -MinimumVersion '1.5.0' -# Should find the DSC resource "TestDscResource" from the latest, non-prerelease module "TestDscResourceModuleName" that has a maximum version of 1.5.0 -Find-PSResource "TestDscResource" -ModuleName "TestDscResourceModuleName" -MaximumVersion "1.5.0" +# Should find the DSC resource 'TestDscResource' from the latest, non-prerelease module 'TestDscResourceModuleName' that has a maximum version of 1.5.0 +Find-PSResource 'TestDscResource' -ModuleName 'TestDscResourceModuleName' -MaximumVersion '1.5.0' -# Should find the DSC resource "TestDscResource" from the latest, non-prelease module "TestDscResourceModuleName" that has a minimum version of 1.0.0 and a maximum version of 2.0.0 -Find-PSResource "TestDscResource" -ModuleName "TestDscResourceModuleName" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" +# Should find the DSC resource 'TestDscResource' from the latest, non-prelease module 'TestDscResourceModuleName' that has a minimum version of 1.0.0 and a maximum version of 2.0.0 +Find-PSResource 'TestDscResource' -ModuleName 'TestDscResourceModuleName' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' -# Should find the DSC resource "TestDscResource" from the module "TestDscResourceModuleName" that has a required version of 1.5.0 (non-prerelease) -Find-PSResource "TestDscResource" -ModuleName "TestDscResourceModuleName" -RequiredVersion "1.5.0" +# Should find the DSC resource 'TestDscResource' from the module 'TestDscResourceModuleName' that has a required version of 1.5.0 (non-prerelease) +Find-PSResource 'TestDscResource' -ModuleName 'TestDscResourceModuleName' -RequiredVersion '1.5.0' -# Should find the DSC resource "TestDscResource" from all non-prerelease versions of the module "TestDscResourceModuleName" -Find-PSResource "TestDscResource" -ModuleName "TestDscResourceModuleName" -AllVersions +# Should find the DSC resource 'TestDscResource' from all non-prerelease versions of the module 'TestDscResourceModuleName' +Find-PSResource 'TestDscResource' -ModuleName 'TestDscResourceModuleName' -AllVersions -# Should find the DSC resource "TestDscResource" from the latest module "TestDscResourceModuleName", including prerelease versions -Find-PSResource "TestDscResource" -ModuleName "TestDscResourceModuleName" -Prerelease +# Should find the DSC resource 'TestDscResource' from the latest module 'TestDscResourceModuleName', including prerelease versions +Find-PSResource 'TestDscResource' -ModuleName 'TestDscResourceModuleName' -Prerelease -# Should find the DSC resource "TestDscResource" from a resource with the tags "Tag1", "Tag2", "Tag3" -Find-PSResource "TestDscResource" -Tag "Tag1", "Tag2", "Tag3" +# Should find the DSC resource 'TestDscResource' from a resource with the tags 'Tag1', 'Tag2', 'Tag3' +Find-PSResource 'TestDscResource' -Tag 'Tag1', 'Tag2', 'Tag3' -# Should find the DSC resource "TestDscResource" from a resource that has "Test" in either the module name or description -Find-PSResource "TestDscResource" -Filter "Test" +# Should find the DSC resource 'TestDscResource' from a resource that has 'Test' in either the module name or description +Find-PSResource 'TestDscResource' -Filter 'Test' -# Should find the DSC resource "TestDscResource" from one of the specified repositories -Find-PSResource "TestDscResource" -Repository "Repository1", "Repository2" +# Should find the DSC resource 'TestDscResource' from one of the specified repositories +Find-PSResource 'TestDscResource' -Repository 'Repository1', 'Repository2' -# Should NOT find the DSC resource "TestDscResource" -Find-PSResource "TestDscResource" -Type "DscResource" +# Should NOT find the DSC resource 'TestDscResource' +Find-PSResource 'TestDscResource' -Type 'DscResource' ### Find role capability ### -# Should find the role capability "TestRoleCapability" -Find-PSResource -name "TestRoleCapability" +# Should find the role capability 'TestRoleCapability' +Find-PSResource -name 'TestRoleCapability' -# Should find the role capability "TestRoleCapability" -Find-PSResource "TestRoleCapability" +# Should find the role capability 'TestRoleCapability' +Find-PSResource 'TestRoleCapability' -# Should find the role capability "TestRoleCapability" -Find-PSResource "TestRoleCapability" -Type "DscResource" +# Should find the role capability 'TestRoleCapability' +Find-PSResource 'TestRoleCapability' -Type 'DscResource' -# Should find the role capability "TestRoleCapability" -Find-PSResource "TestRoleCapability" -Type "Command", "DscResource", "RoleCapability", "Module", "Script" +# Should find the role capability 'TestRoleCapability' +Find-PSResource 'TestRoleCapability' -Type 'Command', 'DscResource', 'RoleCapability', 'Module', 'Script' -# Should find the role capability "TestRoleCapability" from the module -Find-PSResource "TestRoleCapability" -ModuleName "TestDscResourceModuleName" +# Should find the role capability 'TestRoleCapability' from the module +Find-PSResource 'TestRoleCapability' -ModuleName 'TestDscResourceModuleName' -# Should find the role capability "TestRoleCapability" from the latest, non-prerelease module "TestDscResourceModuleName" that has a minimum version 1.5.0 -Find-PSResource "TestRoleCapability" -ModuleName "TestDscResourceModuleName" -MinimumVersion "1.5.0" +# Should find the role capability 'TestRoleCapability' from the latest, non-prerelease module 'TestDscResourceModuleName' that has a minimum version 1.5.0 +Find-PSResource 'TestRoleCapability' -ModuleName 'TestDscResourceModuleName' -MinimumVersion '1.5.0' -# Should find the role capability "TestRoleCapability" from the latest, non-prerelease modules with name "TestDscResourceModuleName" that has a maximum version of 1.5.0 -Find-PSResource "TestRoleCapability" -ModuleName "TestDscResourceModuleName" -MaximumVersion "1.5.0" +# Should find the role capability 'TestRoleCapability' from the latest, non-prerelease modules with name 'TestDscResourceModuleName' that has a maximum version of 1.5.0 +Find-PSResource 'TestRoleCapability' -ModuleName 'TestDscResourceModuleName' -MaximumVersion '1.5.0' -# Should find the command "TestRoleCapability" from the latest, non-prerelease module with name "TestDscResourceModuleName" that has a minimum version of 1.0.0 and a maximum version of 2.0.0 -Find-PSResource "TestRoleCapability" -ModuleName "TestDscResourceModuleName" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" +# Should find the command 'TestRoleCapability' from the latest, non-prerelease module with name 'TestDscResourceModuleName' that has a minimum version of 1.0.0 and a maximum version of 2.0.0 +Find-PSResource 'TestRoleCapability' -ModuleName 'TestDscResourceModuleName' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' -# Should find the role capability "TestRoleCapability" from the module "TestDscResourceModuleName" that has a required version of 1.5.0 (non-prerelease) -Find-PSResource "TestRoleCapability" -ModuleName "TestDscResourceModuleName" -RequiredVersion "1.5.0" +# Should find the role capability 'TestRoleCapability' from the module 'TestDscResourceModuleName' that has a required version of 1.5.0 (non-prerelease) +Find-PSResource 'TestRoleCapability' -ModuleName 'TestDscResourceModuleName' -RequiredVersion '1.5.0' -# Should find the role capability "TestRoleCapability" from all non-prerelease versions of the module "TestDscResourceModuleName" -Find-PSResource "TestRoleCapability" -ModuleName "TestDscResourceModuleName" -AllVersions +# Should find the role capability 'TestRoleCapability' from all non-prerelease versions of the module 'TestDscResourceModuleName' +Find-PSResource 'TestRoleCapability' -ModuleName 'TestDscResourceModuleName' -AllVersions -# Should find the role capability "TestRoleCapability" from the module "TestDscresourceModuleName", including prerelease versions -Find-PSResource "TestRoleCapability" -ModuleName "TestDscResourceModuleName" -Prerelease +# Should find the role capability 'TestRoleCapability' from the module 'TestDscresourceModuleName', including prerelease versions +Find-PSResource 'TestRoleCapability' -ModuleName 'TestDscResourceModuleName' -Prerelease -# Should find the role capability "TestRoleCapability" from a resource with the tags "Tag1", "Tag2", "Tag3" -Find-PSResource "TestRoleCapability" -Tag "Tag1", "Tag2", "Tag3" +# Should find the role capability 'TestRoleCapability' from a resource with the tags 'Tag1', 'Tag2', 'Tag3' +Find-PSResource 'TestRoleCapability' -Tag 'Tag1', 'Tag2', 'Tag3' -# Should find the role capability "TestRoleCapability" from a resource that has "Test" in either the module name or description -Find-PSResource "TestRoleCapability" -Filter "Test" +# Should find the role capability 'TestRoleCapability' from a resource that has 'Test' in either the module name or description +Find-PSResource 'TestRoleCapability' -Filter 'Test' -# Should find the role capability "TestRoleCapability" from one of the specified repositories -Find-PSResource "TestRoleCapability" -Repository "Repository1", "Repository2" +# Should find the role capability 'TestRoleCapability' from one of the specified repositories +Find-PSResource 'TestRoleCapability' -Repository 'Repository1', 'Repository2' -# Should NOT find the role capability "TestRoleCapability" -Find-PSResource "TestRoleCapability" -Type "TestDscResource" +# Should NOT find the role capability 'TestRoleCapability' +Find-PSResource 'TestRoleCapability' -Type 'TestDscResource' ### Find module ### -# Should find the module "TestModule" -Find-PSResource -name "TestModule" +# Should find the module 'TestModule' +Find-PSResource -name 'TestModule' -# Should find the module "TestModule" -Find-PSResource "TestModule" +# Should find the module 'TestModule' +Find-PSResource 'TestModule' -# Should find the module "TestModule" -Find-PSResource "TestModule" -Type "Module" +# Should find the module 'TestModule' +Find-PSResource 'TestModule' -Type 'Module' -# Should find the module "TestModule" -Find-PSResource "TestModule" -Type "Command", "DscResource", "RoleCapability", "Module", "Script" +# Should find the module 'TestModule' +Find-PSResource 'TestModule' -Type 'Command', 'DscResource', 'RoleCapability', 'Module', 'Script' -# Should find the non-prerelase module "TestModule" that has a minimum version of 1.5.0 -Find-PSResource "TestModule" -MinimumVersion "1.5.0" +# Should find the non-prerelase module 'TestModule' that has a minimum version of 1.5.0 +Find-PSResource 'TestModule' -MinimumVersion '1.5.0' -# Should find the non-prerelease module "TestModule" that has a maximum version of 1.5.0 -Find-PSResource "TestModule" -MaximumVersion "1.5.0" +# Should find the non-prerelease module 'TestModule' that has a maximum version of 1.5.0 +Find-PSResource 'TestModule' -MaximumVersion '1.5.0' -# Should find the non-prerelease module "TestModule" that has a minimum version of 1.0.0 and a maximum version of 1.5.0 -Find-PSResource "TestModule" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" +# Should find the non-prerelease module 'TestModule' that has a minimum version of 1.0.0 and a maximum version of 1.5.0 +Find-PSResource 'TestModule' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' -# Should find the latest, non-prerelease scripts "TestModule" that is exactly version 1.5.0 -Find-PSResource "TestModule" -RequiredVersion "1.5.0" +# Should find the latest, non-prerelease scripts 'TestModule' that is exactly version 1.5.0 +Find-PSResource 'TestModule' -RequiredVersion '1.5.0' -# Should find all versions of all non-prerelease versions of the module "TestModule" -Find-PSResource "TestModule" -AllVersions +# Should find all versions of all non-prerelease versions of the module 'TestModule' +Find-PSResource 'TestModule' -AllVersions -# Should find the lastest, non-prerelease version of the module "TestModule", including prerelease versions -Find-PSResource "TestModule" -Prerelease +# Should find the lastest, non-prerelease version of the module 'TestModule', including prerelease versions +Find-PSResource 'TestModule' -Prerelease -# Should find the module "TestModule" with the tags "Tag1", "Tag2", "Tag3" -Find-PSResource "TestModule" -Tag "Tag1", "Tag2", "Tag3" +# Should find the module 'TestModule' with the tags 'Tag1', 'Tag2', 'Tag3' +Find-PSResource 'TestModule' -Tag 'Tag1', 'Tag2', 'Tag3' -# Should find the module "TestModule" that has "Test" in either the module name or description -Find-PSResource "TestModule" -Filter "Test" +# Should find the module 'TestModule' that has 'Test' in either the module name or description +Find-PSResource 'TestModule' -Filter 'Test' -# Should find the module "TestModule" from all of the specified repositories -Find-PSResource "TestModule" -Repository "Repository1", "Repository2" +# Should find the module 'TestModule' from all of the specified repositories +Find-PSResource 'TestModule' -Repository 'Repository1', 'Repository2' -# Should find the module "TestModule" and all modules that are dependent upon "TestModule" -Find-PSResource "TestModule" -IncludeDependencies +# Should find the module 'TestModule' and all modules that are dependent upon 'TestModule' +Find-PSResource 'TestModule' -IncludeDependencies -# Should find the module "TestModule" that has DSC resources -Find-PSResource "TestModule" -Includes 'DscResource' +# Should find the module 'TestModule' that has DSC resources +Find-PSResource 'TestModule' -Includes 'DscResource' -# Should find the module "TestModule" that has DSC resources named "TestDscResource" -Find-PSResource "TestModule" -DSCResource "TestDscResource" +# Should find the module 'TestModule' that has DSC resources named 'TestDscResource' +Find-PSResource 'TestModule' -DSCResource 'TestDscResource' -# Should find the module "TestModule" that has a role capacity named "TestDscResource" -Find-PSResource "TestModule" -RoleCapability "TestRoleCapability" +# Should find the module 'TestModule' that has a role capacity named 'TestDscResource' +Find-PSResource 'TestModule' -RoleCapability 'TestRoleCapability' -# Should find the module "TestModule" that has a command named "Test-Command" -Find-PSResource "TestModule" -Command "Test-Command" +# Should find the module 'TestModule' that has a command named 'Test-Command' +Find-PSResource 'TestModule' -Command 'Test-Command' ### Find Script ### -# Should find the script named "TestScript" -Find-PSResource -name "TestScript" +# Should find the script named 'TestScript' +Find-PSResource -name 'TestScript' -# Should find the script named "TestScript" -Find-PSResource "TestScript" +# Should find the script named 'TestScript' +Find-PSResource 'TestScript' -# Should find the script named "TestScript" -Find-PSResource "TestScript" -Type "Script" +# Should find the script named 'TestScript' +Find-PSResource 'TestScript' -Type 'Script' -# Should find the script named "TestScript" -Find-PSResource "TestScript" -Type "Command", "DscResource", "RoleCapability", "Module", "Script" +# Should find the script named 'TestScript' +Find-PSResource 'TestScript' -Type 'Command', 'DscResource', 'RoleCapability', 'Module', 'Script' -# Should find the latest, non-prerelease script "TestScript" that has a minimum version of 1.5.0 -Find-PSResource "TestScript" -MinimumVersion "1.5.0" +# Should find the latest, non-prerelease script 'TestScript' that has a minimum version of 1.5.0 +Find-PSResource 'TestScript' -MinimumVersion '1.5.0' -# Should find the latest, non-prerelease script "TestScript" that have a maximum version of 1.5.0 -Find-PSResource "TestScript" -MaximumVersion "1.5.0" +# Should find the latest, non-prerelease script 'TestScript' that have a maximum version of 1.5.0 +Find-PSResource 'TestScript' -MaximumVersion '1.5.0' -# Should find the latest, non-prerelease script "TestScript" that has a minimum version of 1.0.0 and a maximum version of 1.5.0 -Find-PSResource "TestScript" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" +# Should find the latest, non-prerelease script 'TestScript' that has a minimum version of 1.0.0 and a maximum version of 1.5.0 +Find-PSResource 'TestScript' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' -# Should find the latest, non-prerelease scripts "TestScript" that is exactly version 1.5.0 -Find-PSResource "TestScript" -RequiredVersion "1.5.0" +# Should find the latest, non-prerelease scripts 'TestScript' that is exactly version 1.5.0 +Find-PSResource 'TestScript' -RequiredVersion '1.5.0' -# Should find all versions of all scripts named "TestScript", not including prerelease versions -Find-PSResource "TestScript" -AllVersions +# Should find all versions of all scripts named 'TestScript', not including prerelease versions +Find-PSResource 'TestScript' -AllVersions -# Should find the script "TestScript", including prerelease versions -Find-PSResource "TestScript" -AllowPrerelease +# Should find the script 'TestScript', including prerelease versions +Find-PSResource 'TestScript' -AllowPrerelease -# Should find the script "TestScript" with the tags "Tag1", "Tag2", "Tag3" -Find-PSResource "TestScript" -Tag "Tag1", "Tag2", "Tag3" +# Should find the script 'TestScript' with the tags 'Tag1', 'Tag2', 'Tag3' +Find-PSResource 'TestScript' -Tag 'Tag1', 'Tag2', 'Tag3' -# Should find the script "TestScript" that has "Test" in either the script name or description -Find-PSResource "TestScript" -Filter "Test" +# Should find the script 'TestScript' that has 'Test' in either the script name or description +Find-PSResource 'TestScript' -Filter 'Test' -# Should find the script "TestScript" from all of the specified repositories -Find-PSResource "TestScript" -Repository "Repository1", "Repository2" +# Should find the script 'TestScript' from all of the specified repositories +Find-PSResource 'TestScript' -Repository 'Repository1', 'Repository2' -# Should find the script "TestScript" and all modules that are dependent upon "TestScript" -Find-PSResource "TestScript" -IncludeDependencies +# Should find the script 'TestScript' and all modules that are dependent upon 'TestScript' +Find-PSResource 'TestScript' -IncludeDependencies -# Should find the script "TestScript" that has a function named "TestFunction" -Find-PSResource "TestScript" -Includes 'TestFunction' +# Should find the script 'TestScript' that has a function named 'TestFunction' +Find-PSResource 'TestScript' -Includes 'TestFunction' -# Should find the script "TestScript" that has a command named "Test-Command" -Find-PSResource "TestScript" -Command "Test-Command" +# Should find the script 'TestScript' that has a command named 'Test-Command' +Find-PSResource 'TestScript' -Command 'Test-Command' ### Find multiple resources ### -# Should find the resources "TestResource1", "TestResource2", "TestResource3" -Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" +# Should find the resources 'TestResource1', 'TestResource2', 'TestResource3' +Find-PSResource -name 'TestResource1', 'TestResource2', 'TestResource3' -# Should find the resource "TestResource1", "TestResource2", "TestResource3" -Find-PSResource "TestResource1", "TestResource2", "TestResource3" +# Should find the resource 'TestResource1', 'TestResource2', 'TestResource3' +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -# Should find the resources "TestResource1", "TestResource2", "TestResource3" -Find-PSResource "TestResource1", "TestResource2", "TestResource3" -Type "Module" +# Should find the resources 'TestResource1', 'TestResource2', 'TestResource3' +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -Type 'Module' -# Should find the "TestResource1", "TestResource2", "TestResource3" -Find-PSResource "TestResource1", "TestResource2", "TestResource3" -Type "Command", "DscResource", "RoleCapability", "Module", "Script" +# Should find the 'TestResource1', 'TestResource2', 'TestResource3' +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -Type 'Command', 'DscResource', 'RoleCapability', 'Module', 'Script' -# Should find the latest, non-prerelease modules "TestResource1", "TestResource2", "TestResource3" that have a minimum version of 1.5.0 -Find-PSResource "TestResource1", "TestResource2", "TestResource3" -MinimumVersion "1.5.0" +# Should find the latest, non-prerelease modules 'TestResource1', 'TestResource2', 'TestResource3' that have a minimum version of 1.5.0 +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -MinimumVersion '1.5.0' -# Should find the latest, non-prerelease modules "TestResource1", "TestResource2", "TestResource3" that have a maximum version of 1.5.0 -Find-PSResource "TestResource1", "TestResource2", "TestResource3" -MaximumVersion "1.5.0" +# Should find the latest, non-prerelease modules 'TestResource1', 'TestResource2', 'TestResource3' that have a maximum version of 1.5.0 +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -MaximumVersion '1.5.0' -# Should find the latest, non-prerelease modules "TestResource1", "TestResource2", "TestResource3" that have a minimum version of 1.0.0 and a maximum version of 1.5.0 -Find-PSResource "TestResource1", "TestResource2", "TestResource3" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" +# Should find the latest, non-prerelease modules 'TestResource1', 'TestResource2', 'TestResource3' that have a minimum version of 1.0.0 and a maximum version of 1.5.0 +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' -# Should find the modules "TestResource1", "TestResource2", "TestResource3" that are exactly version 1.5.0 -Find-PSResource "TestResource1", "TestResource2", "TestResource3" -RequiredVersion "1.5.0" +# Should find the modules 'TestResource1', 'TestResource2', 'TestResource3' that are exactly version 1.5.0 +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -RequiredVersion '1.5.0' -# Should find all non-prerelease versions of the modules "TestResource1", "TestResource2", "TestResource3", not including prerelease versions -Find-PSResource "TestResource1", "TestResource2", "TestResource3" -AllVersions +# Should find all non-prerelease versions of the modules 'TestResource1', 'TestResource2', 'TestResource3', not including prerelease versions +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -AllVersions -# Should find the modules "TestResource1", "TestResource2", "TestResource3", including prerelease versions -Find-PSResource "TestResource1", "TestResource2", "TestResource3" -Prerelease +# Should find the modules 'TestResource1', 'TestResource2', 'TestResource3', including prerelease versions +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -Prerelease -# Should find the modules "TestResource1", "TestResource2", "TestResource3" with the tags "Tag1", "Tag2", "Tag3" -Find-PSResource "TestResource1", "TestResource2", "TestResource3" -Tag "Tag1", "Tag2", "Tag3" +# Should find the modules 'TestResource1', 'TestResource2', 'TestResource3' with the tags 'Tag1', 'Tag2', 'Tag3' +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -Tag 'Tag1', 'Tag2', 'Tag3' -# Should find the modules "TestResource1", "TestResource2", "TestResource3" that have "Test" in either the module name or description -Find-PSResource "TestResource1", "TestResource2", "TestResource3" -Filter "Test" +# Should find the modules 'TestResource1', 'TestResource2', 'TestResource3' that have 'Test' in either the module name or description +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -Filter 'Test' -# Should find the modules "TestResource1", "TestResource2", "TestResource3" from all of the specified repositories -Find-PSResource "TestResource1", "TestResource2", "TestResource3" -Repository "Repository1", "Repository2" +# Should find the modules 'TestResource1', 'TestResource2', 'TestResource3' from all of the specified repositories +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -Repository 'Repository1', 'Repository2' -# Should find the modules "TestResource1", "TestResource2", "TestResource3" and all modules that are dependent upon "TestResource1", "TestResource2", "TestResource3" -Find-PSResource "TestResource1", "TestResource2", "TestResource3" -IncludeDependencies +# Should find the modules 'TestResource1', 'TestResource2', 'TestResource3' and all modules that are dependent upon 'TestResource1', 'TestResource2', 'TestResource3' +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -IncludeDependencies -# Should find the modules "TestResource1", "TestResource2", "TestResource3" that have DSC resources -Find-PSResource "TestResource1", "TestResource2", "TestResource3" -Includes 'DscResource' +# Should find the modules 'TestResource1', 'TestResource2', 'TestResource3' that have DSC resources +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -Includes 'DscResource' -# Should find the modules "TestResource1", "TestResource2", "TestResource3" that have DSC resources named "TestDscResource" -Find-PSResource "TestResource1", "TestResource2", "TestResource3" -DSCResource "TestDscResource" +# Should find the modules 'TestResource1', 'TestResource2', 'TestResource3' that have DSC resources named 'TestDscResource' +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -DSCResource 'TestDscResource' -# Should find all the modules named "TestResource1", "TestResource2", "TestResource3" that have a role capacity named "TestRoleCapacity" -Find-PSResource "TestResource1", "TestResource2", "TestResource3" -RoleCapability "TestRoleCapability" +# Should find all the modules named 'TestResource1', 'TestResource2', 'TestResource3' that have a role capacity named 'TestRoleCapacity' +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -RoleCapability 'TestRoleCapability' -# Should find all the modules named "TestResource1", "TestResource2", "TestResource3" that have a command named "Test-Command" -Find-PSResource "TestResource1", "TestResource2", "TestResource3" -Command "Test-Command" +# Should find all the modules named 'TestResource1', 'TestResource2', 'TestResource3' that have a command named 'Test-Command' +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -Command 'Test-Command' @@ -328,40 +328,40 @@ Install-PSResource -name 'TestModule' # Should install the modules 'TestModule1', 'TestModule2', 'TestModule3' Install-PSResource 'TestModule1', 'TestModule2', 'TestModule3' -# Should install the latest, non-prerelease version of the module "TestModule" that is at least 1.5.0 -Install-PSResource "TestModule" -MinimumVersion "1.5.0" +# Should install the latest, non-prerelease version of the module 'TestModule' that is at least 1.5.0 +Install-PSResource 'TestModule' -MinimumVersion '1.5.0' -# Should install the latest, non-prerelease version of the module "TestModule" that is at most 1.5.0 -Install-PSResource "TestModule" -MaximumVersion "1.5.0" +# Should install the latest, non-prerelease version of the module 'TestModule' that is at most 1.5.0 +Install-PSResource 'TestModule' -MaximumVersion '1.5.0' -# Should install the latest, non-prerelease version of the module "TestModule" that is at least version 1.0.0 and at most 2.0.0 -Install-PSResource "TestModule" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" +# Should install the latest, non-prerelease version of the module 'TestModule' that is at least version 1.0.0 and at most 2.0.0 +Install-PSResource 'TestModule' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' -# Should install version 1.5.0 (non-prerelease) of the module "TestModule" -Install-PSResource "TestModule" -RequiredVersion "1.5.0" +# Should install version 1.5.0 (non-prerelease) of the module 'TestModule' +Install-PSResource 'TestModule' -RequiredVersion '1.5.0' -# Should install the latest verison of "TestModule", including prerelease versions -Install-PSResource "TestModule" -Prerelease +# Should install the latest verison of 'TestModule', including prerelease versions +Install-PSResource 'TestModule' -Prerelease -# Should install "TestModule" from one of the specified repositories (based on repo priority) -Install-PSResource "TestModule" -Repository "Repository1", "Repository2" +# Should install 'TestModule' from one of the specified repositories (based on repo priority) +Install-PSResource 'TestModule' -Repository 'Repository1', 'Repository2' # Should install the module Pester Install-PSResource -RequiredResources @{ - "Configuration" = "[1.3.1,2.0)" - "Pester" = @{ - version = "[4.4.2,4.7.0]" - repository = "https://www.powershellgallery.com" + 'Configuration' = '[1.3.1,2.0)' + 'Pester' = @{ + version = '[4.4.2,4.7.0]' + repository = 'https://www.powershellgallery.com' } } # Should install the module Pester Install-PSResource -RequiredResources ConvertTo-Json ( @{ - "Configuration" = "[1.3.1,2.0)" - "Pester" = @{ - version = "[4.4.2,4.7.0]" - repository = "https://www.powershellgallery.com" + 'Configuration' = '[1.3.1,2.0)' + 'Pester' = @{ + version = '[4.4.2,4.7.0]' + repository = 'https://www.powershellgallery.com' } } ) @@ -372,35 +372,35 @@ Install-PSResource -RequiredResourcesFile 'RequiredResource.psd1' # Should install the required resources in RequiredResource.json Install-PSResource -RequiredResourcesFile 'RequiredResource.json' -# Should install the module "TestModule" to the CurrentUser scope -Install-PSResource "TestModule" -Scope "CurrentUser" +# Should install the module 'TestModule' to the CurrentUser scope +Install-PSResource 'TestModule' -Scope 'CurrentUser' -# Should install the module "TestModule" to the AllUsers scope -Install-PSResource "TestModule" -Scope "AllUsers" +# Should install the module 'TestModule' to the AllUsers scope +Install-PSResource 'TestModule' -Scope 'AllUsers' -# Should install the module "TestModule" without prompting warning message regarding installation conflicts -Install-PSResource "TestModule" -NoClobber +# Should install the module 'TestModule' without prompting warning message regarding installation conflicts +Install-PSResource 'TestModule' -NoClobber -# Should install the module "TestModule" without prompting message regarding publisher mismatch -Install-PSResource "TestModule" -IgnoreDifferentPublisher +# Should install the module 'TestModule' without prompting message regarding publisher mismatch +Install-PSResource 'TestModule' -IgnoreDifferentPublisher -# Should install the module "TestModule" without prompting message regarding untrusted sources -Install-PSResource "TestModule" -TrustRepository +# Should install the module 'TestModule' without prompting message regarding untrusted sources +Install-PSResource 'TestModule' -TrustRepository -# Should install the module "TestModule" without prompting message regarding untrusted sources -Install-PSResource "TestModule" -Force +# Should install the module 'TestModule' without prompting message regarding untrusted sources +Install-PSResource 'TestModule' -Force -# Should reinstall the module "TestModule" -Install-PSResource "TestModule" -Reinstall +# Should reinstall the module 'TestModule' +Install-PSResource 'TestModule' -Reinstall -#Should install the module "TestModule" without displaying progress information -Install-PSResource "TestModule" -Quiet +#Should install the module 'TestModule' without displaying progress information +Install-PSResource 'TestModule' -Quiet -#Should install the module "TestModule" and automatically accept license agreement -Install-PSResource "TestModule" -AcceptLicense +#Should install the module 'TestModule' and automatically accept license agreement +Install-PSResource 'TestModule' -AcceptLicense -#Should install the module "TestModule" and return the module as an object to the console -Install-PSResource "TestModule" -PassThru +#Should install the module 'TestModule' and return the module as an object to the console +Install-PSResource 'TestModule' -PassThru @@ -415,40 +415,40 @@ Install-PSResource -name 'TestScript' # Should install the scripts 'TestScript1', 'TestScript2', 'TestScript3' Install-PSResource 'TestScript1', 'TestScript2', 'TestScript3' -# Should install the latest, non-prerelease version of the script "TestScript" that is at least 1.5.0 -Install-PSResource "TestScript" -MinimumVersion "1.5.0" +# Should install the latest, non-prerelease version of the script 'TestScript' that is at least 1.5.0 +Install-PSResource 'TestScript' -MinimumVersion '1.5.0' -# Should install the latest, non-prerelease version of the script "TestScript" that is at most 1.5.0 -Install-PSResource "TestScript" -MaximumVersion "1.5.0" +# Should install the latest, non-prerelease version of the script 'TestScript' that is at most 1.5.0 +Install-PSResource 'TestScript' -MaximumVersion '1.5.0' -# Should install the latest, non-prerelease version of the script "TestScript" that is at least version 1.0.0 and at most 2.0.0 -Install-PSResource "TestScript" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" +# Should install the latest, non-prerelease version of the script 'TestScript' that is at least version 1.0.0 and at most 2.0.0 +Install-PSResource 'TestScript' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' -# Should install version 1.5.0 (non-prerelease) of the script "TestScript" -Install-PSResource "TestScript" -RequiredVersion "1.5.0" +# Should install version 1.5.0 (non-prerelease) of the script 'TestScript' +Install-PSResource 'TestScript' -RequiredVersion '1.5.0' -# Should install the latest verison of "TestScript", including prerelease versions -Install-PSResource "TestScript" -Prerelease +# Should install the latest verison of 'TestScript', including prerelease versions +Install-PSResource 'TestScript' -Prerelease -# Should install "TestScript" from one of the specified repositories (based on repo priority) -Install-PSResource "TestScript" -Repository "Repository1", "Repository2" +# Should install 'TestScript' from one of the specified repositories (based on repo priority) +Install-PSResource 'TestScript' -Repository 'Repository1', 'Repository2' # Should install the script TestScript Install-PSResource -RequiredResources @{ - "Configuration" = "[1.3.1,2.0)" - "TestScript" = @{ - version = "[4.4.2,4.7.0]" - repository = "https://www.powershellgallery.com" + 'Configuration' = '[1.3.1,2.0)' + 'TestScript' = @{ + version = '[4.4.2,4.7.0]' + repository = 'https://www.powershellgallery.com' } } # Should install the script TestScript Install-PSResource -RequiredResources ConvertTo-Json ( @{ - "Configuration" = "[1.3.1,2.0)" - "TestScript" = @{ - version = "[4.4.2,4.7.0]" - repository = "https://www.powershellgallery.com" + 'Configuration' = '[1.3.1,2.0)' + 'TestScript' = @{ + version = '[4.4.2,4.7.0]' + repository = 'https://www.powershellgallery.com' } } ) @@ -459,32 +459,32 @@ Install-PSResource -RequiredResourcesFile 'RequiredResource.psd1' # Should install the required resources in RequiredResource.json Install-PSResource -RequiredResourcesFile 'RequiredResource.json' -# Should install the script "TestScript" to the CurrentUser scope -Install-PSResource "TestScript" -Scope "CurrentUser" +# Should install the script 'TestScript' to the CurrentUser scope +Install-PSResource 'TestScript' -Scope 'CurrentUser' -# Should install the script "TestScript" to the AllUsers scope -Install-PSResource "TestScript" -Scope "AllUsers" +# Should install the script 'TestScript' to the AllUsers scope +Install-PSResource 'TestScript' -Scope 'AllUsers' -# Should install the module "TestModule" without prompting warning message regarding installation conflicts -Install-PSResource "TestModule" -NoClobber +# Should install the module 'TestModule' without prompting warning message regarding installation conflicts +Install-PSResource 'TestModule' -NoClobber -# Should install the script "TestScript" without prompting message regarding publisher mismatch -Install-PSResource "TestScript" -IgnoreDifferentPublisher +# Should install the script 'TestScript' without prompting message regarding publisher mismatch +Install-PSResource 'TestScript' -IgnoreDifferentPublisher -# Should install the script "TestScript" without prompting message regarding untrusted sources -Install-PSResource "TestScript" -TrustRepository +# Should install the script 'TestScript' without prompting message regarding untrusted sources +Install-PSResource 'TestScript' -TrustRepository -# Should install the script "TestScript" without prompting message regarding untrusted sources -Install-PSResource "TestScript" -Force +# Should install the script 'TestScript' without prompting message regarding untrusted sources +Install-PSResource 'TestScript' -Force -# Should reinstall the script "TestScript" -Install-PSResource "TestScript" -Reinstall +# Should reinstall the script 'TestScript' +Install-PSResource 'TestScript' -Reinstall -#Should install the script "TestScript" without displaying progress information -Install-PSResource "TestScript" -Quiet +#Should install the script 'TestScript' without displaying progress information +Install-PSResource 'TestScript' -Quiet -#Should install the script "TestScript" and automatically accept license agreement -Install-PSResource "TestScript" -AcceptLicense +#Should install the script 'TestScript' and automatically accept license agreement +Install-PSResource 'TestScript' -AcceptLicense -#Should install the script "TestScript" and return the script as an object to the console -Install-PSResource "TestScript" -PassThru +#Should install the script 'TestScript' and return the script as an object to the console +Install-PSResource 'TestScript' -PassThru diff --git a/v3prototype/Install-PSResource.ps1 b/v3prototype/Install-PSResource.ps1 index b7967d2e..06e5f31b 100644 --- a/v3prototype/Install-PSResource.ps1 +++ b/v3prototype/Install-PSResource.ps1 @@ -114,7 +114,7 @@ function Install-PSResource { [PSCredential] $ProxyCredential, - # Specifies a user account that has rights to install a module for a specified package provider or source. + # Specifies a user account that has rights to install a resource from a specific repository. [Parameter(ValueFromPipelineByPropertyName = $true)] [PSCredential] $Credential, diff --git a/v3prototype/Install-PSResourceValidations.ps1 b/v3prototype/Install-PSResourceValidations.ps1 index 3c61ea81..0aad258c 100644 --- a/v3prototype/Install-PSResourceValidations.ps1 +++ b/v3prototype/Install-PSResourceValidations.ps1 @@ -13,40 +13,40 @@ Install-PSResource -name 'TestModule' # Should install the modules 'TestModule1', 'TestModule2', 'TestModule3' Install-PSResource 'TestModule1', 'TestModule2', 'TestModule3' -# Should install the latest, non-prerelease version of the module "TestModule" that is at least 1.5.0 -Install-PSResource "TestModule" -MinimumVersion "1.5.0" +# Should install the latest, non-prerelease version of the module 'TestModule' that is at least 1.5.0 +Install-PSResource 'TestModule' -MinimumVersion '1.5.0' -# Should install the latest, non-prerelease version of the module "TestModule" that is at most 1.5.0 -Install-PSResource "TestModule" -MaximumVersion "1.5.0" +# Should install the latest, non-prerelease version of the module 'TestModule' that is at most 1.5.0 +Install-PSResource 'TestModule' -MaximumVersion '1.5.0' -# Should install the latest, non-prerelease version of the module "TestModule" that is at least version 1.0.0 and at most 2.0.0 -Install-PSResource "TestModule" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" +# Should install the latest, non-prerelease version of the module 'TestModule' that is at least version 1.0.0 and at most 2.0.0 +Install-PSResource 'TestModule' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' -# Should install version 1.5.0 (non-prerelease) of the module "TestModule" -Install-PSResource "TestModule" -RequiredVersion "1.5.0" +# Should install version 1.5.0 (non-prerelease) of the module 'TestModule' +Install-PSResource 'TestModule' -RequiredVersion '1.5.0' -# Should install the latest verison of "TestModule", including prerelease versions -Install-PSResource "TestModule" -Prerelease +# Should install the latest verison of 'TestModule', including prerelease versions +Install-PSResource 'TestModule' -Prerelease -# Should install "TestModule" from one of the specified repositories (based on repo priority) -Install-PSResource "TestModule" -Repository "Repository1", "Repository2" +# Should install 'TestModule' from one of the specified repositories (based on repo priority) +Install-PSResource 'TestModule' -Repository 'Repository1', 'Repository2' # Should install the module Pester Install-PSResource -RequiredResources @{ - "Configuration" = "[1.3.1,2.0)" - "Pester" = @{ - version = "[4.4.2,4.7.0]" - repository = "https://www.powershellgallery.com" + 'Configuration' = '[1.3.1,2.0)' + 'Pester' = @{ + version = '[4.4.2,4.7.0]' + repository = 'https://www.powershellgallery.com' } } # Should install the module Pester Install-PSResource -RequiredResources ConvertTo-Json ( @{ - "Configuration" = "[1.3.1,2.0)" - "Pester" = @{ - version = "[4.4.2,4.7.0]" - repository = "https://www.powershellgallery.com" + 'Configuration' = '[1.3.1,2.0)' + 'Pester' = @{ + version = '[4.4.2,4.7.0]' + repository = 'https://www.powershellgallery.com' } } ) @@ -57,35 +57,35 @@ Install-PSResource -RequiredResourcesFile 'RequiredResource.psd1' # Should install the required resources in RequiredResource.json Install-PSResource -RequiredResourcesFile 'RequiredResource.json' -# Should install the module "TestModule" to the CurrentUser scope -Install-PSResource "TestModule" -Scope "CurrentUser" +# Should install the module 'TestModule' to the CurrentUser scope +Install-PSResource 'TestModule' -Scope 'CurrentUser' -# Should install the module "TestModule" to the AllUsers scope -Install-PSResource "TestModule" -Scope "AllUsers" +# Should install the module 'TestModule' to the AllUsers scope +Install-PSResource 'TestModule' -Scope 'AllUsers' -# Should install the module "TestModule" without prompting warning message regarding installation conflicts -Install-PSResource "TestModule" -NoClobber +# Should install the module 'TestModule' without prompting warning message regarding installation conflicts +Install-PSResource 'TestModule' -NoClobber -# Should install the module "TestModule" without prompting message regarding publisher mismatch -Install-PSResource "TestModule" -IgnoreDifferentPublisher +# Should install the module 'TestModule' without prompting message regarding publisher mismatch +Install-PSResource 'TestModule' -IgnoreDifferentPublisher -# Should install the module "TestModule" without prompting message regarding untrusted sources -Install-PSResource "TestModule" -TrustRepository +# Should install the module 'TestModule' without prompting message regarding untrusted sources +Install-PSResource 'TestModule' -TrustRepository -# Should install the module "TestModule" without prompting message regarding untrusted sources -Install-PSResource "TestModule" -Force +# Should install the module 'TestModule' without prompting message regarding untrusted sources +Install-PSResource 'TestModule' -Force -# Should reinstall the module "TestModule" -Install-PSResource "TestModule" -Reinstall +# Should reinstall the module 'TestModule' +Install-PSResource 'TestModule' -Reinstall -#Should install the module "TestModule" without displaying progress information -Install-PSResource "TestModule" -Quiet +#Should install the module 'TestModule' without displaying progress information +Install-PSResource 'TestModule' -Quiet -#Should install the module "TestModule" and automatically accept license agreement -Install-PSResource "TestModule" -AcceptLicense +#Should install the module 'TestModule' and automatically accept license agreement +Install-PSResource 'TestModule' -AcceptLicense -#Should install the module "TestModule" and return the module as an object to the console -Install-PSResource "TestModule" -PassThru +#Should install the module 'TestModule' and return the module as an object to the console +Install-PSResource 'TestModule' -PassThru @@ -100,40 +100,40 @@ Install-PSResource -name 'TestScript' # Should install the scripts 'TestScript1', 'TestScript2', 'TestScript3' Install-PSResource 'TestScript1', 'TestScript2', 'TestScript3' -# Should install the latest, non-prerelease version of the script "TestScript" that is at least 1.5.0 -Install-PSResource "TestScript" -MinimumVersion "1.5.0" +# Should install the latest, non-prerelease version of the script 'TestScript' that is at least 1.5.0 +Install-PSResource 'TestScript' -MinimumVersion '1.5.0' -# Should install the latest, non-prerelease version of the script "TestScript" that is at most 1.5.0 -Install-PSResource "TestScript" -MaximumVersion "1.5.0" +# Should install the latest, non-prerelease version of the script 'TestScript' that is at most 1.5.0 +Install-PSResource 'TestScript' -MaximumVersion '1.5.0' -# Should install the latest, non-prerelease version of the script "TestScript" that is at least version 1.0.0 and at most 2.0.0 -Install-PSResource "TestScript" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" +# Should install the latest, non-prerelease version of the script 'TestScript' that is at least version 1.0.0 and at most 2.0.0 +Install-PSResource 'TestScript' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' -# Should install version 1.5.0 (non-prerelease) of the script "TestScript" -Install-PSResource "TestScript" -RequiredVersion "1.5.0" +# Should install version 1.5.0 (non-prerelease) of the script 'TestScript' +Install-PSResource 'TestScript' -RequiredVersion '1.5.0' -# Should install the latest verison of "TestScript", including prerelease versions -Install-PSResource "TestScript" -Prerelease +# Should install the latest verison of 'TestScript', including prerelease versions +Install-PSResource 'TestScript' -Prerelease -# Should install "TestScript" from one of the specified repositories (based on repo priority) -Install-PSResource "TestScript" -Repository "Repository1", "Repository2" +# Should install 'TestScript' from one of the specified repositories (based on repo priority) +Install-PSResource 'TestScript' -Repository 'Repository1', 'Repository2' # Should install the script TestScript Install-PSResource -RequiredResources @{ - "Configuration" = "[1.3.1,2.0)" - "TestScript" = @{ - version = "[4.4.2,4.7.0]" - repository = "https://www.powershellgallery.com" + 'Configuration' = '[1.3.1,2.0)' + 'TestScript' = @{ + version = '[4.4.2,4.7.0]' + repository = 'https://www.powershellgallery.com' } } # Should install the script TestScript Install-PSResource -RequiredResources ConvertTo-Json ( @{ - "Configuration" = "[1.3.1,2.0)" - "TestScript" = @{ - version = "[4.4.2,4.7.0]" - repository = "https://www.powershellgallery.com" + 'Configuration' = '[1.3.1,2.0)' + 'TestScript' = @{ + version = '[4.4.2,4.7.0]' + repository = 'https://www.powershellgallery.com' } } ) @@ -144,32 +144,32 @@ Install-PSResource -RequiredResourcesFile 'RequiredResource.psd1' # Should install the required resources in RequiredResource.json Install-PSResource -RequiredResourcesFile 'RequiredResource.json' -# Should install the script "TestScript" to the CurrentUser scope -Install-PSResource "TestScript" -Scope "CurrentUser" +# Should install the script 'TestScript' to the CurrentUser scope +Install-PSResource 'TestScript' -Scope 'CurrentUser' -# Should install the script "TestScript" to the AllUsers scope -Install-PSResource "TestScript" -Scope "AllUsers" +# Should install the script 'TestScript' to the AllUsers scope +Install-PSResource 'TestScript' -Scope 'AllUsers' -# Should install the module "TestModule" without prompting warning message regarding installation conflicts -Install-PSResource "TestModule" -NoClobber +# Should install the module 'TestModule' without prompting warning message regarding installation conflicts +Install-PSResource 'TestModule' -NoClobber -# Should install the script "TestScript" without prompting message regarding publisher mismatch -Install-PSResource "TestScript" -IgnoreDifferentPublisher +# Should install the script 'TestScript' without prompting message regarding publisher mismatch +Install-PSResource 'TestScript' -IgnoreDifferentPublisher -# Should install the script "TestScript" without prompting message regarding untrusted sources -Install-PSResource "TestScript" -TrustRepository +# Should install the script 'TestScript' without prompting message regarding untrusted sources +Install-PSResource 'TestScript' -TrustRepository -# Should install the script "TestScript" without prompting message regarding untrusted sources -Install-PSResource "TestScript" -Force +# Should install the script 'TestScript' without prompting message regarding untrusted sources +Install-PSResource 'TestScript' -Force -# Should reinstall the script "TestScript" -Install-PSResource "TestScript" -Reinstall +# Should reinstall the script 'TestScript' +Install-PSResource 'TestScript' -Reinstall -#Should install the script "TestScript" without displaying progress information -Install-PSResource "TestScript" -Quiet +#Should install the script 'TestScript' without displaying progress information +Install-PSResource 'TestScript' -Quiet -#Should install the script "TestScript" and automatically accept license agreement -Install-PSResource "TestScript" -AcceptLicense +#Should install the script 'TestScript' and automatically accept license agreement +Install-PSResource 'TestScript' -AcceptLicense -#Should install the script "TestScript" and return the script as an object to the console -Install-PSResource "TestScript" -PassThru +#Should install the script 'TestScript' and return the script as an object to the console +Install-PSResource 'TestScript' -PassThru diff --git a/v3prototype/PSResourceValidation.ps1 b/v3prototype/PSResourceValidation.ps1 index d357ab0f..132863ed 100644 --- a/v3prototype/PSResourceValidation.ps1 +++ b/v3prototype/PSResourceValidation.ps1 @@ -3,323 +3,308 @@ ####################### ### Find command ### -# Should find the command "TestCommand" -Find-PSResource -name "TestCommand" +# Should find the command 'TestCommand' +Find-PSResource -name 'TestCommand' -# Should find the command "TestCommand" -Find-PSResource "TestCommand" +# Should find the command 'TestCommand' +Find-PSResource 'TestCommand' -# Should find the command "TestCommand" -Find-PSResource "TestCommand" -Type "Command" +# Should find the command 'TestCommand' +Find-PSResource 'TestCommand' -Type 'Command' -# Should find the command "TestCommand" -Find-PSResource "TestCommand" -Type "Command","DscResource", "RoleCapability","Module", "Script" +# Should find the command 'TestCommand' +Find-PSResource 'TestCommand' -Type 'Command', 'DscResource', 'RoleCapability', 'Module', 'Script' -# Should find the command "TestCommand" from all the modules with name "TestCommandModuleName" (default to the latest [minor?] version) -Find-PSResource -name "TestCommand" -ModuleName "TestCommandModuleName" +# Should find the command 'TestCommand' from the module 'TestCommandModuleName' +Find-PSResource 'TestCommand' -ModuleName 'TestCommandModuleName' -# Should find the command "TestCommand" from all the modules with name "TestCommandModuleName" that have a minimum version 1.5.0, not including prerelease versions -Find-PSResource -name "TestCommand" -ModuleName "TestCommandModuleName" -MinimumVersion "1.5.0" +# Should find the command 'TestCommand' from the latest, non-prerelease module 'TestCommandModuleName' that has a minimum version 1.5.0 +Find-PSResource 'TestCommand' -ModuleName 'TestCommandModuleName' -MinimumVersion '1.5.0' -# Should find the command "TestCommand" from all the modules with name "TestCommandModuleName" that have a maximum version of 1.5.0, not including prerelease versions -Find-PSResource -name "TestCommand" -ModuleName "TestCommandModuleName" -MaximumVersion "1.5.0" +# Should find the command 'TestCommand' from the latest, non-prerelease module 'TestCommandModuleName' that has a maximum version of 1.5.0 +Find-PSResource 'TestCommand' -ModuleName 'TestCommandModuleName' -MaximumVersion '1.5.0' -# Should find the command "TestCommand" from all the modules with name "TestCommandModuleName" that have a minimum version of 1.0.0 and a maximum version of 2.0.0, not including prerelease versions -Find-PSResource -name "TestCommand" -ModuleName "TestCommandModuleName" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" +# Should find the command 'TestCommand' from the latest, non-prerelease module 'TestCommandModuleName' that has a minimum version of 1.0.0 and a maximum version of 2.0.0 +Find-PSResource 'TestCommand' -ModuleName 'TestCommandModuleName' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' -# Should find the command "TestCommand" from all the modules with name "TestCommandModuleName" that have a required version of 1.5.0, not including prerelease versions -Find-PSResource -name "TestCommand" -ModuleName "TestCommandModuleName" -RequiredVersion "1.5.0" +# Should find the command 'TestCommand' from the module 'TestCommandModuleName' that is exactly version 1.5.0 (non-prerelease) +Find-PSResource 'TestCommand' -ModuleName 'TestCommandModuleName' -RequiredVersion '1.5.0' -# Should find the command "TestCommand" from all versions of the module "TestCommandModuleName", not including prerelease versions -Find-PSResource -name "TestCommand" -ModuleName "TestCommandModuleName" -AllVersions +# Should find the command 'TestCommand' from all non-prerelease versions of the module 'TestCommandModuleName' +Find-PSResource 'TestCommand' -ModuleName 'TestCommandModuleName' -AllVersions -# Should find the command "TestCommand" from the resource (latest version), including prerelease versions -Find-PSResource -name "TestCommand" -ModuleName "TestCommandModuleName" -AllowPrerelease +# Should find the command 'TestCommand' from the latest verions of the module 'TestCommandModuleName', including prerelease versions +Find-PSResource 'TestCommand' -ModuleName 'TestCommandModuleName' -Prerelease -# Should find the command "TestCommand" from a resource with the tags "Tag1", "Tag2", "Tag3" -Find-PSResource -name "TestCommand" -Tag "Tag1","Tag2","Tag3" +# Should find the command 'TestCommand' from a resource with the tags 'Tag1', 'Tag2', 'Tag3' +Find-PSResource 'TestCommand' -Tag 'Tag1', 'Tag2', 'Tag3' -# Should find the command "TestCommand" from a resource that has "Test" in either the module name or description -Find-PSResource -name "TestCommand" -Filter "Test" +# Should find the command 'TestCommand' from a resource that has 'Test' in either the module name or description +Find-PSResource 'TestCommand' -Filter 'Test' -# Should find the command "TestCommand" from one of the specified repositories -Find-PSResource -name "TestCommand" -Repository "Repository1", "Repository2" +# Should find the command 'TestCommand' from one of the specified repositories +Find-PSResource 'TestCommand' -Repository 'Repository1', 'Repository2' -# Should NOT find the command "TestCommand" -Find-PSResource "TestCommand" -Type "TestDscResource" +# Should NOT find the command 'TestCommand' +Find-PSResource 'TestCommand' -Type 'TestDscResource' ### Find DSC resource ### -# Should find the DSC resource "TestDscResource" -Find-PSResource -name "TestDscResource" +# Should find the DSC resource 'TestDscResource' +Find-PSResource -name 'TestDscResource' -# Should find the DSC resource "TestDscResource" -Find-PSResource "TestDscResource" +# Should find the DSC resource 'TestDscResource' +Find-PSResource 'TestDscResource' -# Should find the DSC resource "TestDscResource" -Find-PSResource "TestDscResource" -Type "DscResource" +# Should find the DSC resource 'TestDscResource' +Find-PSResource 'TestDscResource' -Type 'DscResource' -# Should find the DSC resource "TestDscResource" -Find-PSResource "TestDscResource" -Type "Command","DscResource", "RoleCapability","Module", "Script" +# Should find the DSC resource 'TestDscResource' +Find-PSResource 'TestDscResource' -Type 'Command', 'DscResource', 'RoleCapability', 'Module', 'Script' -# Should find the DSC resource "TestDscResource" that is contained within the module "TestDscResourceModuleName" (default to the latest [minor?] version) -Find-PSResource -name "TestDscResource" -ModuleName "TestDscResourceModuleName" +# Should find the DSC resource 'TestDscResource' that is contained within the module 'TestDscResourceModuleName' +Find-PSResource 'TestDscResource' -ModuleName 'TestDscResourceModuleName' -# Should find the DSC resource "TestDscResource" from all the modules with name "TestDscResourceModuleName" that have a minimum version 1.5.0, not including prerelease versions -Find-PSResource -name "TestDscResource" -ModuleName "TestDscResourceModuleName" -MinimumVersion "1.5.0" +# Should find the DSC resource 'TestDscResource' from the latest, non-prerelease module 'TestDscResourceModuleName' that has a minimum version 1.5.0 +Find-PSResource 'TestDscResource' -ModuleName 'TestDscResourceModuleName' -MinimumVersion '1.5.0' -# Should find the DSC resource "TestDscResource" from all the modules with name "TestDscResourceModuleName" that have a maximum version of 1.5.0, not including prerelease versions -Find-PSResource -name "TestDscResource" -ModuleName "TestDscResourceModuleName" -MaximumVersion "1.5.0" +# Should find the DSC resource 'TestDscResource' from the latest, non-prerelease module 'TestDscResourceModuleName' that has a maximum version of 1.5.0 +Find-PSResource 'TestDscResource' -ModuleName 'TestDscResourceModuleName' -MaximumVersion '1.5.0' -# Should find the command "TestDscResource" from all the modules with name "TestDscResourceModuleName" that have a minimum version of 1.0.0 and a maximum version of 2.0.0, not including prerelease versions -Find-PSResource -name "TestDscResource" -ModuleName "TestDscResourceModuleName" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" +# Should find the DSC resource 'TestDscResource' from the latest, non-prelease module 'TestDscResourceModuleName' that has a minimum version of 1.0.0 and a maximum version of 2.0.0 +Find-PSResource 'TestDscResource' -ModuleName 'TestDscResourceModuleName' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' -# Should find the DSC resource "TestDscResource" from all the modules with name "TestDscResourceModuleName" that have a required version of 1.5.0, not including prerelease versions -Find-PSResource -name "TestDscResource" -ModuleName "TestDscResourceModuleName" -RequiredVersion "1.5.0" +# Should find the DSC resource 'TestDscResource' from the module 'TestDscResourceModuleName' that has a required version of 1.5.0 (non-prerelease) +Find-PSResource 'TestDscResource' -ModuleName 'TestDscResourceModuleName' -RequiredVersion '1.5.0' -# Should find the DSC resource "TestDscResource" from all versions of the module "TestDscResourceModuleName", not including prerelease versions -Find-PSResource -name "TestDscResource" -ModuleName "TestDscResourceModuleName" -AllVersions +# Should find the DSC resource 'TestDscResource' from all non-prerelease versions of the module 'TestDscResourceModuleName' +Find-PSResource 'TestDscResource' -ModuleName 'TestDscResourceModuleName' -AllVersions -# Should find the DSC resource "TestDscResource" from the resource (latest version), including prerelease versions -Find-PSResource -name "TestDscResource" -ModuleName "TestDscResourceModuleName" -AllowPrerelease +# Should find the DSC resource 'TestDscResource' from the latest module 'TestDscResourceModuleName', including prerelease versions +Find-PSResource 'TestDscResource' -ModuleName 'TestDscResourceModuleName' -Prerelease -# Should find the DSC resource "TestDscResource" from a resource with the tags "Tag1", "Tag2", "Tag3" -Find-PSResource -name "TestDscResource" -Tag "Tag1","Tag2","Tag3" +# Should find the DSC resource 'TestDscResource' from a resource with the tags 'Tag1', 'Tag2', 'Tag3' +Find-PSResource 'TestDscResource' -Tag 'Tag1', 'Tag2', 'Tag3' -# Should find the DSC resource "TestDscResource" from a resource that has "Test" in either the module name or description -Find-PSResource -name "TestDscResource" -Filter "Test" +# Should find the DSC resource 'TestDscResource' from a resource that has 'Test' in either the module name or description +Find-PSResource 'TestDscResource' -Filter 'Test' -# Should find the DSC resource "TestDscResource" from one of the specified repositories -Find-PSResource -name "TestDscResource" -Repository "Repository1", "Repository2" +# Should find the DSC resource 'TestDscResource' from one of the specified repositories +Find-PSResource 'TestDscResource' -Repository 'Repository1', 'Repository2' -# Should NOT find the DSC resource "TestDscResource" -Find-PSResource "TestDscResource" -Type "DscResource" +# Should NOT find the DSC resource 'TestDscResource' +Find-PSResource 'TestDscResource' -Type 'DscResource' ### Find role capability ### -# Should find the role capability "TestRoleCapability" -Find-PSResource -name "TestRoleCapability" +# Should find the role capability 'TestRoleCapability' +Find-PSResource -name 'TestRoleCapability' -# Should find the role capability "TestRoleCapability" -Find-PSResource "TestRoleCapability" +# Should find the role capability 'TestRoleCapability' +Find-PSResource 'TestRoleCapability' -# Should find the role capability "TestRoleCapability" -Find-PSResource "TestRoleCapability" -Type "DscResource" +# Should find the role capability 'TestRoleCapability' +Find-PSResource 'TestRoleCapability' -Type 'DscResource' -# Should find the role capability "TestRoleCapability" -Find-PSResource "TestRoleCapability" -Type "Command","DscResource", "RoleCapability","Module", "Script" +# Should find the role capability 'TestRoleCapability' +Find-PSResource 'TestRoleCapability' -Type 'Command', 'DscResource', 'RoleCapability', 'Module', 'Script' -# Should find the role capability "TestRoleCapability" from the module (default to the latest [minor?] version) -Find-PSResource -name "TestRoleCapability" -ModuleName "TestDscResourceModuleName" +# Should find the role capability 'TestRoleCapability' from the module +Find-PSResource 'TestRoleCapability' -ModuleName 'TestDscResourceModuleName' -# Should find the role capability "TestRoleCapability" from all the modules with name "TestDscResourceModuleName" that have a minimum version 1.5.0, not including prerelease versions -Find-PSResource -name "TestRoleCapability" -ModuleName "TestDscResourceModuleName" -MinimumVersion "1.5.0" +# Should find the role capability 'TestRoleCapability' from the latest, non-prerelease module 'TestDscResourceModuleName' that has a minimum version 1.5.0 +Find-PSResource 'TestRoleCapability' -ModuleName 'TestDscResourceModuleName' -MinimumVersion '1.5.0' -# Should find the role capability "TestRoleCapability" from all the modules with name "TestDscResourceModuleName" that have a maximum version of 1.5.0, not including prerelease versions -Find-PSResource -name "TestRoleCapability" -ModuleName "TestDscResourceModuleName" -MaximumVersion "1.5.0" +# Should find the role capability 'TestRoleCapability' from the latest, non-prerelease modules with name 'TestDscResourceModuleName' that has a maximum version of 1.5.0 +Find-PSResource 'TestRoleCapability' -ModuleName 'TestDscResourceModuleName' -MaximumVersion '1.5.0' -# Should find the command "TestRoleCapability" from all the modules with name "TestDscResourceModuleName" that have a minimum version of 1.0.0 and a maximum version of 2.0.0, not including prerelease versions -Find-PSResource -name "TestRoleCapability" -ModuleName "TestDscResourceModuleName" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" +# Should find the command 'TestRoleCapability' from the latest, non-prerelease module with name 'TestDscResourceModuleName' that has a minimum version of 1.0.0 and a maximum version of 2.0.0 +Find-PSResource 'TestRoleCapability' -ModuleName 'TestDscResourceModuleName' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' -# Should find the role capability "TestRoleCapability" from all the modules with name "TestDscResourceModuleName" that have a required version of 1.5.0, not including prerelease versions -Find-PSResource -name "TestRoleCapability" -ModuleName "TestDscResourceModuleName" -RequiredVersion "1.5.0" +# Should find the role capability 'TestRoleCapability' from the module 'TestDscResourceModuleName' that has a required version of 1.5.0 (non-prerelease) +Find-PSResource 'TestRoleCapability' -ModuleName 'TestDscResourceModuleName' -RequiredVersion '1.5.0' -# Should find the role capability "TestRoleCapability" from the resource (lists all versions), not including prerelease versions -Find-PSResource -name "TestRoleCapability" -ModuleName "TestDscResourceModuleName" -AllVersions +# Should find the role capability 'TestRoleCapability' from all non-prerelease versions of the module 'TestDscResourceModuleName' +Find-PSResource 'TestRoleCapability' -ModuleName 'TestDscResourceModuleName' -AllVersions -# Should find the role capability "TestRoleCapability" from the resource (latest version), including prerelease versions -Find-PSResource -name "TestRoleCapability" -ModuleName "TestDscResourceModuleName" -AllowPrerelease +# Should find the role capability 'TestRoleCapability' from the module 'TestDscresourceModuleName', including prerelease versions +Find-PSResource 'TestRoleCapability' -ModuleName 'TestDscResourceModuleName' -Prerelease -# Should find the role capability "TestRoleCapability" from a resource with the tags "Tag1", "Tag2", "Tag3" -Find-PSResource -name "TestRoleCapability" -Tag "Tag1","Tag2","Tag3" +# Should find the role capability 'TestRoleCapability' from a resource with the tags 'Tag1', 'Tag2', 'Tag3' +Find-PSResource 'TestRoleCapability' -Tag 'Tag1', 'Tag2', 'Tag3' -# Should find the role capability "TestRoleCapability" from a resource that has "Test" in either the module name or description -Find-PSResource -name "TestRoleCapability" -Filter "Test" +# Should find the role capability 'TestRoleCapability' from a resource that has 'Test' in either the module name or description +Find-PSResource 'TestRoleCapability' -Filter 'Test' -# Should find the role capability "TestRoleCapability" from one of the specified repositories -Find-PSResource -name "TestRoleCapability" -Repository "Repository1", "Repository2" +# Should find the role capability 'TestRoleCapability' from one of the specified repositories +Find-PSResource 'TestRoleCapability' -Repository 'Repository1', 'Repository2' -# Should NOT find the role capability "TestRoleCapability" -Find-PSResource "TestRoleCapability" -Type "TestDscResource" +# Should NOT find the role capability 'TestRoleCapability' +Find-PSResource 'TestRoleCapability' -Type 'TestDscResource' ### Find module ### -# Should find the module "TestModule" -Find-PSResource -name "TestModule" +# Should find the module 'TestModule' +Find-PSResource -name 'TestModule' -# Should find the module "TestModule" -Find-PSResource "TestModule" +# Should find the module 'TestModule' +Find-PSResource 'TestModule' -# Should find the module "TestModule" -Find-PSResource "TestModule" -Type "Module" +# Should find the module 'TestModule' +Find-PSResource 'TestModule' -Type 'Module' -# Should find the module "TestModule" -Find-PSResource "TestModule" -Type "Command","DscResource", "RoleCapability","Module", "Script" +# Should find the module 'TestModule' +Find-PSResource 'TestModule' -Type 'Command', 'DscResource', 'RoleCapability', 'Module', 'Script' -# Should find all modules named "TestModule" that have a minimum version of 1.5.0, not including prerelease versions -Find-PSResource -name "TestModule" -MinimumVersion "1.5.0" +# Should find the non-prerelase module 'TestModule' that has a minimum version of 1.5.0 +Find-PSResource 'TestModule' -MinimumVersion '1.5.0' -# Should find all modules named "TestModule" that have a maximum version of 1.5.0, not including prerelease versions -Find-PSResource -name "TestModule" -MaximumVersion "1.5.0" +# Should find the non-prerelease module 'TestModule' that has a maximum version of 1.5.0 +Find-PSResource 'TestModule' -MaximumVersion '1.5.0' -# Should find all modules named "TestModule" that have a minimum version of 1.0.0 and a maximum version of 1.5.0, not including prerelease versions -Find-PSResource -name "TestModule" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" +# Should find the non-prerelease module 'TestModule' that has a minimum version of 1.0.0 and a maximum version of 1.5.0 +Find-PSResource 'TestModule' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' -# Should find all the modules named "TestModule" that is version 1.5.0 -Find-PSResource -name "TestModule" -RequiredVersion "1.5.0" +# Should find the latest, non-prerelease scripts 'TestModule' that is exactly version 1.5.0 +Find-PSResource 'TestModule' -RequiredVersion '1.5.0' -# Should find all versions of all modules named "TestModule", not including prerelease versions -Find-PSResource -name "TestModule" -AllVersions +# Should find all versions of all non-prerelease versions of the module 'TestModule' +Find-PSResource 'TestModule' -AllVersions -# Should find all modules named "TestModule", including prerelease versions -Find-PSResource -name "TestModule" -AllowPrerelease +# Should find the lastest, non-prerelease version of the module 'TestModule', including prerelease versions +Find-PSResource 'TestModule' -Prerelease -# Should find all the modules named "TestModule" with the tags "Tag1", "Tag2", "Tag3" -Find-PSResource -name "TestModule" -Tag "Tag1","Tag2","Tag3" +# Should find the module 'TestModule' with the tags 'Tag1', 'Tag2', 'Tag3' +Find-PSResource 'TestModule' -Tag 'Tag1', 'Tag2', 'Tag3' -# Should find all the modules named "TestModule" that have "Test" in either the module name or description -Find-PSResource -name "TestModule" -Filter "Test" +# Should find the module 'TestModule' that has 'Test' in either the module name or description +Find-PSResource 'TestModule' -Filter 'Test' -# Should find all the modules named "TestModule" from all of the specified repositories -Find-PSResource -name "TestModule" -Repository "Repository1", "Repository2" +# Should find the module 'TestModule' from all of the specified repositories +Find-PSResource 'TestModule' -Repository 'Repository1', 'Repository2' -# Should find all the modules named "TestModule" and all modules that are dependent upon "TestModule" -Find-PSResource -name "TestModule" -IncludeDependencies +# Should find the module 'TestModule' and all modules that are dependent upon 'TestModule' +Find-PSResource 'TestModule' -IncludeDependencies -# Should find all the modules named "TestModule" that have DSC resources -Find-PSResource -name "TestModule" -Includes 'DscResource' +# Should find the module 'TestModule' that has DSC resources +Find-PSResource 'TestModule' -Includes 'DscResource' -# Should find all the modules named "TestModule" that have DSC resources named "TestDscResource" -Find-PSResource -name "TestModule" -DSCResource "TestDscResource" +# Should find the module 'TestModule' that has DSC resources named 'TestDscResource' +Find-PSResource 'TestModule' -DSCResource 'TestDscResource' -# Should find all the modules named "TestModule" that have a role capacity named "TestDscResource" -Find-PSResource -name "TestModule" -RoleCapability "TestRoleCapability" +# Should find the module 'TestModule' that has a role capacity named 'TestDscResource' +Find-PSResource 'TestModule' -RoleCapability 'TestRoleCapability' -# Should find all the modules named "TestModule" that have a command named "Test-Command" -Find-PSResource -name "TestModule" -Command "Test-Command" +# Should find the module 'TestModule' that has a command named 'Test-Command' +Find-PSResource 'TestModule' -Command 'Test-Command' ### Find Script ### -# Should find all scripts named "TestScript" -Find-PSResource -name "TestScript" +# Should find the script named 'TestScript' +Find-PSResource -name 'TestScript' -# Should find all scripts named "TestScript" -Find-PSResource "TestScript" +# Should find the script named 'TestScript' +Find-PSResource 'TestScript' -# Should find all scripts named "TestScript" -Find-PSResource "TestScript" -Type "Script" +# Should find the script named 'TestScript' +Find-PSResource 'TestScript' -Type 'Script' -# Should find all scripts named "TestScript" -Find-PSResource "TestScript" -Type "Command","DscResource", "RoleCapability","Module", "Script" +# Should find the script named 'TestScript' +Find-PSResource 'TestScript' -Type 'Command', 'DscResource', 'RoleCapability', 'Module', 'Script' -# Should find all scripts named "TestScript" that have a minimum version of 1.5.0, not including prerelease versions -Find-PSResource -name "TestScript" -MinimumVersion "1.5.0" +# Should find the latest, non-prerelease script 'TestScript' that has a minimum version of 1.5.0 +Find-PSResource 'TestScript' -MinimumVersion '1.5.0' -# Should find all scripts named "TestScript" that have a maximum version of 1.5.0, not including prerelease versions -Find-PSResource -name "TestScript" -MaximumVersion "1.5.0" +# Should find the latest, non-prerelease script 'TestScript' that have a maximum version of 1.5.0 +Find-PSResource 'TestScript' -MaximumVersion '1.5.0' -# Should find all scripts named "TestScript" that have a minimum version of 1.0.0 and a maximum version of 1.5.0, not including prerelease versions -Find-PSResource -name "TestScript" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" +# Should find the latest, non-prerelease script 'TestScript' that has a minimum version of 1.0.0 and a maximum version of 1.5.0 +Find-PSResource 'TestScript' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' -# Should find all the scripts named "TestScript" that is version 1.5.0 -Find-PSResource -name "TestScript" -RequiredVersion "1.5.0" +# Should find the latest, non-prerelease scripts 'TestScript' that is exactly version 1.5.0 +Find-PSResource 'TestScript' -RequiredVersion '1.5.0' -# Should find all versions of all scripts named "TestScript", not including prerelease versions -Find-PSResource -name "TestScript" -AllVersions +# Should find all versions of all scripts named 'TestScript', not including prerelease versions +Find-PSResource 'TestScript' -AllVersions -# Should find all scripts named "TestScript", including prerelease versions -Find-PSResource -name "TestScript" -AllowPrerelease +# Should find the script 'TestScript', including prerelease versions +Find-PSResource 'TestScript' -AllowPrerelease -# Should find all the scripts named "TestScript" with the tags "Tag1", "Tag2", "Tag3" -Find-PSResource -name "TestScript" -Tag "Tag1","Tag2","Tag3" +# Should find the script 'TestScript' with the tags 'Tag1', 'Tag2', 'Tag3' +Find-PSResource 'TestScript' -Tag 'Tag1', 'Tag2', 'Tag3' -# Should find all the scripts named "TestScript" that have "Test" in either the script name or description -Find-PSResource -name "TestScript" -Filter "Test" +# Should find the script 'TestScript' that has 'Test' in either the script name or description +Find-PSResource 'TestScript' -Filter 'Test' -# Should find all the scripts named "TestScript" from all of the specified repositories -Find-PSResource -name "TestScript" -Repository "Repository1", "Repository2" +# Should find the script 'TestScript' from all of the specified repositories +Find-PSResource 'TestScript' -Repository 'Repository1', 'Repository2' -# Should find all the scripts named "TestScript" and all modules that are dependent upon "TestScript" -Find-PSResource -name "TestScript" -IncludeDependencies +# Should find the script 'TestScript' and all modules that are dependent upon 'TestScript' +Find-PSResource 'TestScript' -IncludeDependencies -# Should find all the scripts named "TestScript" that have a function named "TestFunction" -Find-PSResource -name "TestScript" -Includes 'TestFunction' +# Should find the script 'TestScript' that has a function named 'TestFunction' +Find-PSResource 'TestScript' -Includes 'TestFunction' -# Should find all the modules named "TestScript" that have a command named "Test-Command" -Find-PSResource -name "TestScript" -Command "Test-Command" +# Should find the script 'TestScript' that has a command named 'Test-Command' +Find-PSResource 'TestScript' -Command 'Test-Command' ### Find multiple resources ### -# Should find the resources "TestResource1", "TestResource2", "TestResource3" -Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" +# Should find the resources 'TestResource1', 'TestResource2', 'TestResource3' +Find-PSResource -name 'TestResource1', 'TestResource2', 'TestResource3' -# Should find the resource "TestResource1", "TestResource2", "TestResource3" -Find-PSResource "TestResource1", "TestResource2", "TestResource3" +# Should find the resource 'TestResource1', 'TestResource2', 'TestResource3' +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -# Should find the resources "TestResource1", "TestResource2", "TestResource3" -Find-PSResource "TestResource1", "TestResource2", "TestResource3" -Type "Module" +# Should find the resources 'TestResource1', 'TestResource2', 'TestResource3' +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -Type 'Module' -# Should find the "TestResource1", "TestResource2", "TestResource3" -Find-PSResource "TestResource1", "TestResource2", "TestResource3" -Type "Command","DscResource", "RoleCapability","Module", "Script" +# Should find the 'TestResource1', 'TestResource2', 'TestResource3' +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -Type 'Command', 'DscResource', 'RoleCapability', 'Module', 'Script' -# Should find all modules named "TestResource1", "TestResource2", "TestResource3" that have a minimum version of 1.5.0, not including prerelease versions -Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -MinimumVersion "1.5.0" +# Should find the latest, non-prerelease modules 'TestResource1', 'TestResource2', 'TestResource3' that have a minimum version of 1.5.0 +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -MinimumVersion '1.5.0' -# Should find all modules named "TestResource1", "TestResource2", "TestResource3" that have a maximum version of 1.5.0, not including prerelease versions -Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -MaximumVersion "1.5.0" +# Should find the latest, non-prerelease modules 'TestResource1', 'TestResource2', 'TestResource3' that have a maximum version of 1.5.0 +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -MaximumVersion '1.5.0' -# Should find all modules named "TestResource1", "TestResource2", "TestResource3" that have a minimum version of 1.0.0 and a maximum version of 1.5.0, not including prerelease versions -Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" +# Should find the latest, non-prerelease modules 'TestResource1', 'TestResource2', 'TestResource3' that have a minimum version of 1.0.0 and a maximum version of 1.5.0 +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' -# Should find all the modules named "TestResource1", "TestResource2", "TestResource3" that is version 1.5.0 -Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -RequiredVersion "1.5.0" +# Should find the modules 'TestResource1', 'TestResource2', 'TestResource3' that are exactly version 1.5.0 +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -RequiredVersion '1.5.0' -# Should find all versions of all modules named "TestResource1", "TestResource2", "TestResource3", not including prerelease versions -Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -AllVersions +# Should find all non-prerelease versions of the modules 'TestResource1', 'TestResource2', 'TestResource3', not including prerelease versions +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -AllVersions -# Should find all modules named "TestResource1", "TestResource2", "TestResource3", including prerelease versions -Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -AllowPrerelease +# Should find the modules 'TestResource1', 'TestResource2', 'TestResource3', including prerelease versions +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -Prerelease -# Should find all the modules named "TestResource1", "TestResource2", "TestResource3" with the tags "Tag1", "Tag2", "Tag3" -Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -Tag "Tag1","Tag2","Tag3" +# Should find the modules 'TestResource1', 'TestResource2', 'TestResource3' with the tags 'Tag1', 'Tag2', 'Tag3' +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -Tag 'Tag1', 'Tag2', 'Tag3' -# Should find all the modules named "TestResource1", "TestResource2", "TestResource3" that have "Test" in either the module name or description -Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -Filter "Test" +# Should find the modules 'TestResource1', 'TestResource2', 'TestResource3' that have 'Test' in either the module name or description +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -Filter 'Test' -# Should find all the modules named "TestResource1", "TestResource2", "TestResource3" from all of the specified repositories -Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -Repository "Repository1", "Repository2" +# Should find the modules 'TestResource1', 'TestResource2', 'TestResource3' from all of the specified repositories +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -Repository 'Repository1', 'Repository2' -# Should find all the modules named "TestResource1", "TestResource2", "TestResource3" and all modules that are dependent upon "TestResource1", "TestResource2", "TestResource3" -Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -IncludeDependencies +# Should find the modules 'TestResource1', 'TestResource2', 'TestResource3' and all modules that are dependent upon 'TestResource1', 'TestResource2', 'TestResource3' +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -IncludeDependencies -# Should find all the modules named "TestResource1", "TestResource2", "TestResource3" that have DSC resources -Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -Includes 'DscResource' +# Should find the modules 'TestResource1', 'TestResource2', 'TestResource3' that have DSC resources +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -Includes 'DscResource' -# Should find all the modules named "TestResource1", "TestResource2", "TestResource3" that have DSC resources named "TestDscResource" -Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -DSCResource "TestDscResource" +# Should find the modules 'TestResource1', 'TestResource2', 'TestResource3' that have DSC resources named 'TestDscResource' +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -DSCResource 'TestDscResource' -# Should find all the modules named "TestResource1", "TestResource2", "TestResource3" that have a role capacity named "TestRoleCapacity" -Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -RoleCapability "TestRoleCapability" +# Should find all the modules named 'TestResource1', 'TestResource2', 'TestResource3' that have a role capacity named 'TestRoleCapacity' +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -RoleCapability 'TestRoleCapability' -# Should find all the modules named "TestResource1", "TestResource2", "TestResource3" that have a command named "Test-Command" -Find-PSResource -name "TestResource1", "TestResource2", "TestResource3" -Command "Test-Command" - - - -########################## -### Install-PSResource ### -########################## - -### Installing Modules ### -Install-PSResource 'TestModule' -Repository 'https://mygallery.com' - -Install-PSResource 'TestModule1', 'TestModule2', 'TestModule3' -Repository 'https://mygallery.com' - - - -### Installing Scripts ### \ No newline at end of file +# Should find all the modules named 'TestResource1', 'TestResource2', 'TestResource3' that have a command named 'Test-Command' +Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -Command 'Test-Command' diff --git a/v3prototype/RepositoryValidations.ps1 b/v3prototype/RepositoryValidations.ps1 index fc846baf..e683b10d 100644 --- a/v3prototype/RepositoryValidations.ps1 +++ b/v3prototype/RepositoryValidations.ps1 @@ -4,30 +4,30 @@ # Should register the PowerShell Gallery Register-PSRepository -PSGallery -# Should register the repository "TestRepo" -Register-PSResourceRepository "TestRepo" "www.testrepo.com" +# Should register the repository 'TestRepo' +Register-PSResourceRepository 'TestRepo' 'www.testrepo.com' -# Should register the repository "TestRepo" -Register-PSResourceRepository -name "TestRepo" -url "www.testrepo.com" +# Should register the repository 'TestRepo' +Register-PSResourceRepository -name 'TestRepo' -url 'www.testrepo.com' -# Should register the repository "TestRepo" as trusted, priority should be set to 0 -Register-PSResourceRepository -name "TestRepo" -url "www.testrepo.com" -Trusted +# Should register the repository 'TestRepo' as trusted, priority should be set to 0 +Register-PSResourceRepository -name 'TestRepo' -url 'www.testrepo.com' -Trusted -# Should register the repository "TestRepo" with a priority of 2 -Register-PSResourceRepository -name "TestRepo" -url "www.testrepo.com" -Priority 2 +# Should register the repository 'TestRepo' with a priority of 2 +Register-PSResourceRepository -name 'TestRepo' -url 'www.testrepo.com' -Priority 2 ### Repositories -# Should register the repositories "TestRepo1", "TestRepo2", "PSGallery" +# Should register the repositories 'TestRepo1', 'TestRepo2', 'PSGallery' Register-PSResourceRepository -Repositories @( - @{ Name = "TestRepo1"; URL = "https://testrepo1.com"; Trusted = $true; Credential = $cred } - @{ Name = "TestRepo2"; URL = "\\server\share\myrepository"; Trusted = $true } + @{ Name = 'TestRepo1'; URL = 'https://testrepo1.com'; Trusted = $true; Credential = $cred } + @{ Name = 'TestRepo2'; URL = '\\server\share\myrepository'; Trusted = $true } @{ Default = $true; Trusted = $true } ) -# Should return the repositories "TestRepo1", "TestRepo2", "PSGallery" +# Should return the repositories 'TestRepo1', 'TestRepo2', 'PSGallery' $repos = @( - @{ Name = "TestRepo1"; URL = "https://testrepo1.com"; Trusted = $true; } - @{ Name = "TestRepo2"; URL = "\\server\share\myrepository"; Trusted = $true } + @{ Name = 'TestRepo1'; URL = 'https://testrepo1.com'; Trusted = $true; } + @{ Name = 'TestRepo2'; URL = '\\server\share\myrepository'; Trusted = $true } @{ Default = $true; Trusted = $true } ) $repos | Register-PSResourceRepository @@ -40,56 +40,56 @@ $repos | Register-PSResourceRepository # Should return all repositories Get-PSResourceRepository -# Should return the repository "TestRepo" -Get-PSResourceRepository "TestRepo" +# Should return the repository 'TestRepo' +Get-PSResourceRepository 'TestRepo' -# Should return the repository "TestRepo" -Get-PSResourceRepository -name "TestRepo" +# Should return the repository 'TestRepo' +Get-PSResourceRepository -name 'TestRepo' -# Should return the repositories "TestRepo1", "TestRepo2", "TestRepo3" -Get-PSResourceRepository "TestRepo1", "TestRepo2", "TestRepo3" +# Should return the repositories 'TestRepo1', 'TestRepo2', 'TestRepo3' +Get-PSResourceRepository 'TestRepo1', 'TestRepo2', 'TestRepo3' -# Should return the repositories "TestRepo1", "TestRepo2", "TestRepo3" -Get-PSResourceRepository -name "TestRepo1", "TestRepo2", "TestRepo3" +# Should return the repositories 'TestRepo1', 'TestRepo2', 'TestRepo3' +Get-PSResourceRepository -name 'TestRepo1', 'TestRepo2', 'TestRepo3' -# Should return the repository "TestRepo" -"TestRepo1" | Get-PSResourceRepository +# Should return the repository 'TestRepo' +'TestRepo1' | Get-PSResourceRepository -# Should return the repositories "TestRepo1", "TestRepo2", "TestRepo3" -"TestRepo1", "TestRepo2", "TestRepo3" | Get-PSResourceRepository +# Should return the repositories 'TestRepo1', 'TestRepo2', 'TestRepo3' +'TestRepo1', 'TestRepo2', 'TestRepo3' | Get-PSResourceRepository ################################ ### Set-PSResourceRepository ### ################################ -# Should set the repository "TestRepo" to the url "www.testrepo.com" -Set-PSResourceRepository "TestRepo" "www.testrepo.com" +# Should set the repository 'TestRepo' to the url 'www.testrepo.com' +Set-PSResourceRepository 'TestRepo' 'www.testrepo.com' -# Should set the repository "TestRepo" to the url "www.testrepo.com" -Set-PSResourceRepository -name "TestRepo" -url "www.testrepo.com" +# Should set the repository 'TestRepo' to the url 'www.testrepo.com' +Set-PSResourceRepository -name 'TestRepo' -url 'www.testrepo.com' -# Should set the repository "TestRepo" to trusted, with a priority of 0 -Set-PSResourceRepository "TestRepo" -Trusted +# Should set the repository 'TestRepo' to trusted, with a priority of 0 +Set-PSResourceRepository 'TestRepo' -Trusted -# Should set the repository "TestRepo" with a priority of 2 -Set-PSResourceRepository "TestRepo" "www.testrepo.com" -Priority 2 +# Should set the repository 'TestRepo' with a priority of 2 +Set-PSResourceRepository 'TestRepo' 'www.testrepo.com' -Priority 2 -# Should set the repository "TestRepo" -"TestRepo1" | Set-PSResourceRepository -url "www.testrepo.com" +# Should set the repository 'TestRepo' +'TestRepo1' | Set-PSResourceRepository -url 'www.testrepo.com' ### Repositories -# Should set the repositories "TestRepo1", "TestRepo2", "PSGallery" to trusted, with a priority of 0 +# Should set the repositories 'TestRepo1', 'TestRepo2', 'PSGallery' to trusted, with a priority of 0 Set-PSResourceRepository -Repositories @( - @{ Name = "TestRepo1"; URL = "https://testrepo1.com"; Trusted = $true; } - @{ Name = "TestRepo2"; URL = "\\server\share\myrepository"; Trusted = $true } + @{ Name = 'TestRepo1'; URL = 'https://testrepo1.com'; Trusted = $true; } + @{ Name = 'TestRepo2'; URL = '\\server\share\myrepository'; Trusted = $true } @{ Default = $true; Trusted = $true } ) -# Should return the repositories "TestRepo1", "TestRepo2", "PSGallery" +# Should return the repositories 'TestRepo1', 'TestRepo2', 'PSGallery' $repos = @( - @{ Name = "TestRepo1"; URL = "https://testrepo1.com"; Trusted = $true; } - @{ Name = "TestRepo2"; URL = "\\server\share\myrepository"; Trusted = $true } + @{ Name = 'TestRepo1'; URL = 'https://testrepo1.com'; Trusted = $true; } + @{ Name = 'TestRepo2'; URL = '\\server\share\myrepository'; Trusted = $true } @{ Default = $true; Trusted = $true } ) $repos | Set-PSResourceRepository @@ -99,14 +99,14 @@ $repos | Set-PSResourceRepository ####################################### ### Unregister-PSResourceRepository ### ####################################### -# Should unregister the repository "TestRepo" -Unregister-PSResourceRepository -name "TestRepo" +# Should unregister the repository 'TestRepo' +Unregister-PSResourceRepository -name 'TestRepo' -# Should unregister the repositories "TestRepo1", "TestRepo2", "TestRepo3" -Unregister-PSResourceRepository -name "TestRepo1", "TestRepo2", "TestRepo3" +# Should unregister the repositories 'TestRepo1', 'TestRepo2', 'TestRepo3' +Unregister-PSResourceRepository -name 'TestRepo1', 'TestRepo2', 'TestRepo3' -# Should unregister the repository "TestRepo" -"TestRepo1" | Unregister-PSResourceRepository +# Should unregister the repository 'TestRepo' +'TestRepo1' | Unregister-PSResourceRepository -# Should unregister the repositories "TestRepo1", "TestRepo2", "TestRepo3" -"TestRepo1", "TestRepo2", "TestRepo3" | Unregister-PSResourceRepository +# Should unregister the repositories 'TestRepo1', 'TestRepo2', 'TestRepo3' +'TestRepo1', 'TestRepo2', 'TestRepo3' | Unregister-PSResourceRepository From e42d06b3025723c845cef76ad5e9d49140d52bc6 Mon Sep 17 00:00:00 2001 From: Amber Erickson Date: Tue, 13 Aug 2019 18:30:01 -0700 Subject: [PATCH 07/11] Add Update-PSResource cmd and validations --- v3prototype/Update-PSResource.ps1 | 90 +++++++++++++++++++ v3prototype/Update-PSResourceValidations.ps1 | 93 ++++++++++++++++++++ 2 files changed, 183 insertions(+) create mode 100644 v3prototype/Update-PSResource.ps1 create mode 100644 v3prototype/Update-PSResourceValidations.ps1 diff --git a/v3prototype/Update-PSResource.ps1 b/v3prototype/Update-PSResource.ps1 new file mode 100644 index 00000000..46b37a7e --- /dev/null +++ b/v3prototype/Update-PSResource.ps1 @@ -0,0 +1,90 @@ +# Updating resources +function Update-PSResource { + [OutputType([void])] + [cmdletbinding(SupportsShouldProcess = $true)] + Param + ( + # Specifies the names of one or more modules to update. + [Parameter(ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, + Position = 0)] + [ValidateNotNullOrEmpty()] + [String[]] + $Name, + + # Specifies the required version of the resource to include to be updated (cannot use this parameter with the MaximumVersion or UpdateTo parameters). + [Parameter(ValueFromPipelineByPropertyName = $true)] + [ValidateNotNull()] + [string] + $RequiredVersion, + + # Specifies the required version of the resource to include to be updated (cannot use this parameter with the RequiredVersion or UpdateTo parameters). + [Parameter(ValueFromPipelineByPropertyName = $true)] + [ValidateNotNull()] + [string] + $MaximumVersion, + + # Allows updating to latest path version, minor version, or major version (cannot use this parameter with the MaximumVersion or RequiredVersion parameters). + [Parameter(ValueFromPipelineByPropertyName = $true)] + [ValidateSet("PatchVersion", "MinorVersion", "MajorVersion")] + [string] + $UpdateTo, + + # Specifies a user account that has permission to save a resource from a specific repository. + [Parameter(ValueFromPipelineByPropertyName = $true)] + [PSCredential] + $Credential, + + # Saves a resource without asking for user confirmation. + [Parameter()] + [ValidateSet("CurrentUser", "AllUsers")] + [string] + $Scope, + + # Specifies a proxy server for the request, rather than connecting directly to an internet resource. + [Parameter(ValueFromPipelineByPropertyName = $true)] + [ValidateNotNullOrEmpty()] + [Uri] + $Proxy, + + # Specifies a user account that has permission to use the proxy server specified by the Proxy parameter. + [Parameter(ValueFromPipelineByPropertyName = $true)] + [PSCredential] + $ProxyCredential, + + # Updates a resource without asking for user confirmation. + [Parameter()] + [Switch] + $Force, + + # Allows an update to a prerelease version. + [Parameter()] + [Switch] + $Prerelease, + + # Automatically accept the license agreement if the resoruce requires it. + [Parameter()] + [switch] + $AcceptLicense, + + # Returns the resource as an object to the console. + [Parameter()] + [switch] + $PassThru + ) + + begin { } + process { + foreach ($n in $Name) { + if ($pscmdlet.ShouldProcess($n)) { + + if (Get-InstalledResource $n) { + # Use install logic to update resource + write-verbose -message "Successfully updated $n" + } + } + } + } + end { } + +} diff --git a/v3prototype/Update-PSResourceValidations.ps1 b/v3prototype/Update-PSResourceValidations.ps1 new file mode 100644 index 00000000..9d680807 --- /dev/null +++ b/v3prototype/Update-PSResourceValidations.ps1 @@ -0,0 +1,93 @@ +########################## +### Update-PSResource ### +########################## + +### Updating Modules ### + +# Should update the module 'TestModule' +Update-PSResource 'TestModule' + +# Should update the module 'TestModule' +Update-PSResource -name 'TestModule' + +# Should update the modules 'TestModule1', 'TestModule2', 'TestModule3' +Update-PSResource 'TestModule1', 'TestModule2', 'TestModule3' + +# Should update to the latest, non-prerelease version of the module 'TestModule' that is at most 1.5.0 +Update-PSResource 'TestModule' -MaximumVersion '1.5.0' + +# Should update to version 1.5.0 (non-prerelease) of the module 'TestModule' +Update-PSResource 'TestModule' -RequiredVersion '1.5.0' + +# Should update to the latest patch version verison of 'TestModule' +Update-PSResource 'TestModule' -UpdateTo 'PatchVersion' + +# Should update to the latest version verison of 'TestModule' +Update-PSResource 'TestModule' -UpdateTo 'MinorVersion' + +# Should update to the latest major verison of 'TestModule' +Update-PSResource 'TestModule' -UpdateTo 'MinorVersion' + +# Should update to the latest verison of 'TestModule', including prerelease versions +Update-PSResource 'TestModule' -Prerelease + +# Should update the module 'TestModule' to the CurrentUser scope +Update-PSResource 'TestModule' -Scope 'CurrentUser' + +# Should update the module 'TestModule' to the AllUsers scope +Update-PSResource 'TestModule' -Scope 'AllUsers' + +# Should update the module 'TestModule' without asking for user confirmation. +Update-PSResource 'TestModule' -Force + +#Should update the module 'TestModule' and automatically accept license agreement +Update-PSResource 'TestModule' -AcceptLicense + +#Should update the module 'TestModule' and return the module as an object to the console +Update-PSResource 'TestModule' -PassThru + + + +### Updating Scripts ### + +# Should install the script 'TestScript' +Install-PSResource 'TestScript' + +# Should update the script 'TestScript' +Update-PSResource 'TestScript' + +# Should update the script 'TestScript' +Update-PSResource -name 'TestScript' + +# Should update the scripts 'TestScript1', 'TestScript2', 'TestScript3' +Update-PSResource 'TestScript1', 'TestScript2', 'TestScript3' + +# Should update to the latest, non-prerelease version of the script 'TestScript' that is at most 1.5.0 +Update-PSResource 'TestScript' -MaximumVersion '1.5.0' + +# Should update to version 1.5.0 (non-prerelease) of the script 'TestScript' +Update-PSResource 'TestScript' -RequiredVersion '1.5.0' + +# Should update to the latest patch version verison of 'TestScript' +Update-PSResource 'TestScript' -UpdateTo 'PatchVersion' + +# Should update to the latest version verison of 'TestScript' +Update-PSResource 'TestScript' -UpdateTo 'MinorVersion' + +# Should update to the latest major verison of 'TestScript' +Update-PSResource 'TestScript' -UpdateTo 'MinorVersion' + +# Should update to the latest verison of 'TestScript', including prerelease versions +Update-PSResource 'TestScript' -Prerelease + +# Should update the script 'TestScript' to the CurrentUser scope +Update-PSResource 'TestScript' -Scope 'CurrentUser' + +# Should update the script 'TestScript' to the AllUsers scope +Update-PSResource 'TestScript' -Scope 'AllUsers' + +# Should update the script 'TestScript' without asking for user confirmation. +Update-PSResource 'TestScript' -Force + +#Should update the script 'TestScript' and automatically accept license agreement +Update-PSResource 'TestScript' -AcceptLicense From d2abe3b82c8bfe96678a29848010c2ec4d814db5 Mon Sep 17 00:00:00 2001 From: Amber Erickson Date: Tue, 13 Aug 2019 18:30:38 -0700 Subject: [PATCH 08/11] Remove PSResourceValidation file and add syntactic chagnes to Save-Psresource --- v3prototype/PSResourceValidation.ps1 | 310 --------------------------- v3prototype/Save-PSResource.ps1 | 2 +- 2 files changed, 1 insertion(+), 311 deletions(-) delete mode 100644 v3prototype/PSResourceValidation.ps1 diff --git a/v3prototype/PSResourceValidation.ps1 b/v3prototype/PSResourceValidation.ps1 deleted file mode 100644 index 132863ed..00000000 --- a/v3prototype/PSResourceValidation.ps1 +++ /dev/null @@ -1,310 +0,0 @@ -####################### -### Find-PSResource ### -####################### - -### Find command ### -# Should find the command 'TestCommand' -Find-PSResource -name 'TestCommand' - -# Should find the command 'TestCommand' -Find-PSResource 'TestCommand' - -# Should find the command 'TestCommand' -Find-PSResource 'TestCommand' -Type 'Command' - -# Should find the command 'TestCommand' -Find-PSResource 'TestCommand' -Type 'Command', 'DscResource', 'RoleCapability', 'Module', 'Script' - -# Should find the command 'TestCommand' from the module 'TestCommandModuleName' -Find-PSResource 'TestCommand' -ModuleName 'TestCommandModuleName' - -# Should find the command 'TestCommand' from the latest, non-prerelease module 'TestCommandModuleName' that has a minimum version 1.5.0 -Find-PSResource 'TestCommand' -ModuleName 'TestCommandModuleName' -MinimumVersion '1.5.0' - -# Should find the command 'TestCommand' from the latest, non-prerelease module 'TestCommandModuleName' that has a maximum version of 1.5.0 -Find-PSResource 'TestCommand' -ModuleName 'TestCommandModuleName' -MaximumVersion '1.5.0' - -# Should find the command 'TestCommand' from the latest, non-prerelease module 'TestCommandModuleName' that has a minimum version of 1.0.0 and a maximum version of 2.0.0 -Find-PSResource 'TestCommand' -ModuleName 'TestCommandModuleName' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' - -# Should find the command 'TestCommand' from the module 'TestCommandModuleName' that is exactly version 1.5.0 (non-prerelease) -Find-PSResource 'TestCommand' -ModuleName 'TestCommandModuleName' -RequiredVersion '1.5.0' - -# Should find the command 'TestCommand' from all non-prerelease versions of the module 'TestCommandModuleName' -Find-PSResource 'TestCommand' -ModuleName 'TestCommandModuleName' -AllVersions - -# Should find the command 'TestCommand' from the latest verions of the module 'TestCommandModuleName', including prerelease versions -Find-PSResource 'TestCommand' -ModuleName 'TestCommandModuleName' -Prerelease - -# Should find the command 'TestCommand' from a resource with the tags 'Tag1', 'Tag2', 'Tag3' -Find-PSResource 'TestCommand' -Tag 'Tag1', 'Tag2', 'Tag3' - -# Should find the command 'TestCommand' from a resource that has 'Test' in either the module name or description -Find-PSResource 'TestCommand' -Filter 'Test' - -# Should find the command 'TestCommand' from one of the specified repositories -Find-PSResource 'TestCommand' -Repository 'Repository1', 'Repository2' - -# Should NOT find the command 'TestCommand' -Find-PSResource 'TestCommand' -Type 'TestDscResource' - - - -### Find DSC resource ### -# Should find the DSC resource 'TestDscResource' -Find-PSResource -name 'TestDscResource' - -# Should find the DSC resource 'TestDscResource' -Find-PSResource 'TestDscResource' - -# Should find the DSC resource 'TestDscResource' -Find-PSResource 'TestDscResource' -Type 'DscResource' - -# Should find the DSC resource 'TestDscResource' -Find-PSResource 'TestDscResource' -Type 'Command', 'DscResource', 'RoleCapability', 'Module', 'Script' - -# Should find the DSC resource 'TestDscResource' that is contained within the module 'TestDscResourceModuleName' -Find-PSResource 'TestDscResource' -ModuleName 'TestDscResourceModuleName' - -# Should find the DSC resource 'TestDscResource' from the latest, non-prerelease module 'TestDscResourceModuleName' that has a minimum version 1.5.0 -Find-PSResource 'TestDscResource' -ModuleName 'TestDscResourceModuleName' -MinimumVersion '1.5.0' - -# Should find the DSC resource 'TestDscResource' from the latest, non-prerelease module 'TestDscResourceModuleName' that has a maximum version of 1.5.0 -Find-PSResource 'TestDscResource' -ModuleName 'TestDscResourceModuleName' -MaximumVersion '1.5.0' - -# Should find the DSC resource 'TestDscResource' from the latest, non-prelease module 'TestDscResourceModuleName' that has a minimum version of 1.0.0 and a maximum version of 2.0.0 -Find-PSResource 'TestDscResource' -ModuleName 'TestDscResourceModuleName' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' - -# Should find the DSC resource 'TestDscResource' from the module 'TestDscResourceModuleName' that has a required version of 1.5.0 (non-prerelease) -Find-PSResource 'TestDscResource' -ModuleName 'TestDscResourceModuleName' -RequiredVersion '1.5.0' - -# Should find the DSC resource 'TestDscResource' from all non-prerelease versions of the module 'TestDscResourceModuleName' -Find-PSResource 'TestDscResource' -ModuleName 'TestDscResourceModuleName' -AllVersions - -# Should find the DSC resource 'TestDscResource' from the latest module 'TestDscResourceModuleName', including prerelease versions -Find-PSResource 'TestDscResource' -ModuleName 'TestDscResourceModuleName' -Prerelease - -# Should find the DSC resource 'TestDscResource' from a resource with the tags 'Tag1', 'Tag2', 'Tag3' -Find-PSResource 'TestDscResource' -Tag 'Tag1', 'Tag2', 'Tag3' - -# Should find the DSC resource 'TestDscResource' from a resource that has 'Test' in either the module name or description -Find-PSResource 'TestDscResource' -Filter 'Test' - -# Should find the DSC resource 'TestDscResource' from one of the specified repositories -Find-PSResource 'TestDscResource' -Repository 'Repository1', 'Repository2' - -# Should NOT find the DSC resource 'TestDscResource' -Find-PSResource 'TestDscResource' -Type 'DscResource' - - - -### Find role capability ### -# Should find the role capability 'TestRoleCapability' -Find-PSResource -name 'TestRoleCapability' - -# Should find the role capability 'TestRoleCapability' -Find-PSResource 'TestRoleCapability' - -# Should find the role capability 'TestRoleCapability' -Find-PSResource 'TestRoleCapability' -Type 'DscResource' - -# Should find the role capability 'TestRoleCapability' -Find-PSResource 'TestRoleCapability' -Type 'Command', 'DscResource', 'RoleCapability', 'Module', 'Script' - -# Should find the role capability 'TestRoleCapability' from the module -Find-PSResource 'TestRoleCapability' -ModuleName 'TestDscResourceModuleName' - -# Should find the role capability 'TestRoleCapability' from the latest, non-prerelease module 'TestDscResourceModuleName' that has a minimum version 1.5.0 -Find-PSResource 'TestRoleCapability' -ModuleName 'TestDscResourceModuleName' -MinimumVersion '1.5.0' - -# Should find the role capability 'TestRoleCapability' from the latest, non-prerelease modules with name 'TestDscResourceModuleName' that has a maximum version of 1.5.0 -Find-PSResource 'TestRoleCapability' -ModuleName 'TestDscResourceModuleName' -MaximumVersion '1.5.0' - -# Should find the command 'TestRoleCapability' from the latest, non-prerelease module with name 'TestDscResourceModuleName' that has a minimum version of 1.0.0 and a maximum version of 2.0.0 -Find-PSResource 'TestRoleCapability' -ModuleName 'TestDscResourceModuleName' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' - -# Should find the role capability 'TestRoleCapability' from the module 'TestDscResourceModuleName' that has a required version of 1.5.0 (non-prerelease) -Find-PSResource 'TestRoleCapability' -ModuleName 'TestDscResourceModuleName' -RequiredVersion '1.5.0' - -# Should find the role capability 'TestRoleCapability' from all non-prerelease versions of the module 'TestDscResourceModuleName' -Find-PSResource 'TestRoleCapability' -ModuleName 'TestDscResourceModuleName' -AllVersions - -# Should find the role capability 'TestRoleCapability' from the module 'TestDscresourceModuleName', including prerelease versions -Find-PSResource 'TestRoleCapability' -ModuleName 'TestDscResourceModuleName' -Prerelease - -# Should find the role capability 'TestRoleCapability' from a resource with the tags 'Tag1', 'Tag2', 'Tag3' -Find-PSResource 'TestRoleCapability' -Tag 'Tag1', 'Tag2', 'Tag3' - -# Should find the role capability 'TestRoleCapability' from a resource that has 'Test' in either the module name or description -Find-PSResource 'TestRoleCapability' -Filter 'Test' - -# Should find the role capability 'TestRoleCapability' from one of the specified repositories -Find-PSResource 'TestRoleCapability' -Repository 'Repository1', 'Repository2' - -# Should NOT find the role capability 'TestRoleCapability' -Find-PSResource 'TestRoleCapability' -Type 'TestDscResource' - - - -### Find module ### -# Should find the module 'TestModule' -Find-PSResource -name 'TestModule' - -# Should find the module 'TestModule' -Find-PSResource 'TestModule' - -# Should find the module 'TestModule' -Find-PSResource 'TestModule' -Type 'Module' - -# Should find the module 'TestModule' -Find-PSResource 'TestModule' -Type 'Command', 'DscResource', 'RoleCapability', 'Module', 'Script' - -# Should find the non-prerelase module 'TestModule' that has a minimum version of 1.5.0 -Find-PSResource 'TestModule' -MinimumVersion '1.5.0' - -# Should find the non-prerelease module 'TestModule' that has a maximum version of 1.5.0 -Find-PSResource 'TestModule' -MaximumVersion '1.5.0' - -# Should find the non-prerelease module 'TestModule' that has a minimum version of 1.0.0 and a maximum version of 1.5.0 -Find-PSResource 'TestModule' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' - -# Should find the latest, non-prerelease scripts 'TestModule' that is exactly version 1.5.0 -Find-PSResource 'TestModule' -RequiredVersion '1.5.0' - -# Should find all versions of all non-prerelease versions of the module 'TestModule' -Find-PSResource 'TestModule' -AllVersions - -# Should find the lastest, non-prerelease version of the module 'TestModule', including prerelease versions -Find-PSResource 'TestModule' -Prerelease - -# Should find the module 'TestModule' with the tags 'Tag1', 'Tag2', 'Tag3' -Find-PSResource 'TestModule' -Tag 'Tag1', 'Tag2', 'Tag3' - -# Should find the module 'TestModule' that has 'Test' in either the module name or description -Find-PSResource 'TestModule' -Filter 'Test' - -# Should find the module 'TestModule' from all of the specified repositories -Find-PSResource 'TestModule' -Repository 'Repository1', 'Repository2' - -# Should find the module 'TestModule' and all modules that are dependent upon 'TestModule' -Find-PSResource 'TestModule' -IncludeDependencies - -# Should find the module 'TestModule' that has DSC resources -Find-PSResource 'TestModule' -Includes 'DscResource' - -# Should find the module 'TestModule' that has DSC resources named 'TestDscResource' -Find-PSResource 'TestModule' -DSCResource 'TestDscResource' - -# Should find the module 'TestModule' that has a role capacity named 'TestDscResource' -Find-PSResource 'TestModule' -RoleCapability 'TestRoleCapability' - -# Should find the module 'TestModule' that has a command named 'Test-Command' -Find-PSResource 'TestModule' -Command 'Test-Command' - - - -### Find Script ### -# Should find the script named 'TestScript' -Find-PSResource -name 'TestScript' - -# Should find the script named 'TestScript' -Find-PSResource 'TestScript' - -# Should find the script named 'TestScript' -Find-PSResource 'TestScript' -Type 'Script' - -# Should find the script named 'TestScript' -Find-PSResource 'TestScript' -Type 'Command', 'DscResource', 'RoleCapability', 'Module', 'Script' - -# Should find the latest, non-prerelease script 'TestScript' that has a minimum version of 1.5.0 -Find-PSResource 'TestScript' -MinimumVersion '1.5.0' - -# Should find the latest, non-prerelease script 'TestScript' that have a maximum version of 1.5.0 -Find-PSResource 'TestScript' -MaximumVersion '1.5.0' - -# Should find the latest, non-prerelease script 'TestScript' that has a minimum version of 1.0.0 and a maximum version of 1.5.0 -Find-PSResource 'TestScript' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' - -# Should find the latest, non-prerelease scripts 'TestScript' that is exactly version 1.5.0 -Find-PSResource 'TestScript' -RequiredVersion '1.5.0' - -# Should find all versions of all scripts named 'TestScript', not including prerelease versions -Find-PSResource 'TestScript' -AllVersions - -# Should find the script 'TestScript', including prerelease versions -Find-PSResource 'TestScript' -AllowPrerelease - -# Should find the script 'TestScript' with the tags 'Tag1', 'Tag2', 'Tag3' -Find-PSResource 'TestScript' -Tag 'Tag1', 'Tag2', 'Tag3' - -# Should find the script 'TestScript' that has 'Test' in either the script name or description -Find-PSResource 'TestScript' -Filter 'Test' - -# Should find the script 'TestScript' from all of the specified repositories -Find-PSResource 'TestScript' -Repository 'Repository1', 'Repository2' - -# Should find the script 'TestScript' and all modules that are dependent upon 'TestScript' -Find-PSResource 'TestScript' -IncludeDependencies - -# Should find the script 'TestScript' that has a function named 'TestFunction' -Find-PSResource 'TestScript' -Includes 'TestFunction' - -# Should find the script 'TestScript' that has a command named 'Test-Command' -Find-PSResource 'TestScript' -Command 'Test-Command' - - - -### Find multiple resources ### -# Should find the resources 'TestResource1', 'TestResource2', 'TestResource3' -Find-PSResource -name 'TestResource1', 'TestResource2', 'TestResource3' - -# Should find the resource 'TestResource1', 'TestResource2', 'TestResource3' -Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' - -# Should find the resources 'TestResource1', 'TestResource2', 'TestResource3' -Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -Type 'Module' - -# Should find the 'TestResource1', 'TestResource2', 'TestResource3' -Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -Type 'Command', 'DscResource', 'RoleCapability', 'Module', 'Script' - -# Should find the latest, non-prerelease modules 'TestResource1', 'TestResource2', 'TestResource3' that have a minimum version of 1.5.0 -Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -MinimumVersion '1.5.0' - -# Should find the latest, non-prerelease modules 'TestResource1', 'TestResource2', 'TestResource3' that have a maximum version of 1.5.0 -Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -MaximumVersion '1.5.0' - -# Should find the latest, non-prerelease modules 'TestResource1', 'TestResource2', 'TestResource3' that have a minimum version of 1.0.0 and a maximum version of 1.5.0 -Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' - -# Should find the modules 'TestResource1', 'TestResource2', 'TestResource3' that are exactly version 1.5.0 -Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -RequiredVersion '1.5.0' - -# Should find all non-prerelease versions of the modules 'TestResource1', 'TestResource2', 'TestResource3', not including prerelease versions -Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -AllVersions - -# Should find the modules 'TestResource1', 'TestResource2', 'TestResource3', including prerelease versions -Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -Prerelease - -# Should find the modules 'TestResource1', 'TestResource2', 'TestResource3' with the tags 'Tag1', 'Tag2', 'Tag3' -Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -Tag 'Tag1', 'Tag2', 'Tag3' - -# Should find the modules 'TestResource1', 'TestResource2', 'TestResource3' that have 'Test' in either the module name or description -Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -Filter 'Test' - -# Should find the modules 'TestResource1', 'TestResource2', 'TestResource3' from all of the specified repositories -Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -Repository 'Repository1', 'Repository2' - -# Should find the modules 'TestResource1', 'TestResource2', 'TestResource3' and all modules that are dependent upon 'TestResource1', 'TestResource2', 'TestResource3' -Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -IncludeDependencies - -# Should find the modules 'TestResource1', 'TestResource2', 'TestResource3' that have DSC resources -Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -Includes 'DscResource' - -# Should find the modules 'TestResource1', 'TestResource2', 'TestResource3' that have DSC resources named 'TestDscResource' -Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -DSCResource 'TestDscResource' - -# Should find all the modules named 'TestResource1', 'TestResource2', 'TestResource3' that have a role capacity named 'TestRoleCapacity' -Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -RoleCapability 'TestRoleCapability' - -# Should find all the modules named 'TestResource1', 'TestResource2', 'TestResource3' that have a command named 'Test-Command' -Find-PSResource 'TestResource1', 'TestResource2', 'TestResource3' -Command 'Test-Command' diff --git a/v3prototype/Save-PSResource.ps1 b/v3prototype/Save-PSResource.ps1 index a5ec7c26..fba98b15 100644 --- a/v3prototype/Save-PSResource.ps1 +++ b/v3prototype/Save-PSResource.ps1 @@ -59,7 +59,7 @@ function Save-PSResource { [string] $MaximumVersion, - # Specifies the required version of the resource to include to be installed (cannot use this parameter with the MinimumVersion or MaximumVersion parameters). + # Specifies the required version of the resource to include to be saved (cannot use this parameter with the MinimumVersion or MaximumVersion parameters). [Parameter(ValueFromPipelineByPropertyName = $true, ParameterSetName = 'NameAndPathParameterSet')] [Parameter(ValueFromPipelineByPropertyName = $true, From aff2f52e2751f49939ac14356767f897c4ff7fbb Mon Sep 17 00:00:00 2001 From: Amber Erickson Date: Wed, 14 Aug 2019 14:42:11 -0700 Subject: [PATCH 09/11] Add Get-PSResource cmd and validations --- v3prototype/Get-PSResource.ps1 | 83 +++++++++++++++++ v3prototype/Get-PSResourceValidations.ps1 | 104 ++++++++++++++++++++++ 2 files changed, 187 insertions(+) create mode 100644 v3prototype/Get-PSResource.ps1 create mode 100644 v3prototype/Get-PSResourceValidations.ps1 diff --git a/v3prototype/Get-PSResource.ps1 b/v3prototype/Get-PSResource.ps1 new file mode 100644 index 00000000..b13a5d0a --- /dev/null +++ b/v3prototype/Get-PSResource.ps1 @@ -0,0 +1,83 @@ +function Get-PSResource { + [OutputType([PsCustomObject])] + [cmdletbinding(SupportsShouldProcess = $true)] + Param + ( + # Specifies the resources to get. + [Parameter(ValueFromPipelineByPropertyName = $true, + Position = 0)] + [ValidateNotNullOrEmpty()] + [String[]] + $Name, + + # Specifies the type of resource to get. + [Parameter(ValueFromPipelineByPropertyName = $true)] + [ValidateSet('Module', 'Script', 'Nupkg')] + [string[]] + $Type, + + # Specifies the minimum version of the resource to return (cannot use this parameter with the RequiredVersion or AllVersions parameters). + [Parameter(ValueFromPipelineByPropertyName = $true)] + [ValidateNotNull()] + [string] + $MinimumVersion, + + # Specifies the required version of the resource to return (cannot use this parameter with the MinimumVersion, MaximumVersion, or AllVersions parameters). + [Parameter(ValueFromPipelineByPropertyName = $true)] + [ValidateNotNull()] + [string] + $RequiredVersion, + + # Specifies the maximum version of the resource to return (cannot use this parameter with the RequiredVersion or AllVersions parameters). + [Parameter(ValueFromPipelineByPropertyName = $true)] + [ValidateNotNull()] + [string] + $MaximumVersion, + + # Displays all versions of the resource that have been installed (cannot use this parameter with the MinimumVersion, MaximumVersion, or RequiredVersion parameters). + [Parameter()] + [switch] + $AllVersions, + + # Allows returning prerelease versions. + [Parameter()] + [switch] + $Prerelease + ) + + + begin { } + process { + foreach ($n in $Name) { + if ($pscmdlet.ShouldProcess($n)) { + $PSResource = New-Object PSObject -Property @{ + Name = $Name + Version = "placeholder-for-module-version" + Type = "placeholder-for-type" + Description = "placeholder-for-description" + Author = "placeholder-for-author" + CompanyName = "placeholder-for-company-name" + Copyright = "placeholder-for-copyright" + PublishedDate = "placeholder-for-published-date" + InstalledDate = "placeholder-for-installed-date" + UpdatedDate = "placeholder-for-updated-date" + LicenseUri = "placeholder-for-license-uri" + ProjectUri = "placeholder-for-project-uri" + IconUri = "placeholder-for-icon-uri" + Tags = "placeholder-for-tags" + Includes = "placeholder-for-includes" + PowerShellGetFormatVersion = "placeholder-for-powershellget-format-version" + ReleaseNotes = "placeholder-for-release-notes" + Dependencies = "placeholder-for-dependencies" + URL = "placeholder-for-url" + Repository = "placeholder-for-repository" #??? + AdditonalMetadata = "placehodler-for-additional-metadata" + } + + return $PSResource + } + } + } + end { } + +} diff --git a/v3prototype/Get-PSResourceValidations.ps1 b/v3prototype/Get-PSResourceValidations.ps1 new file mode 100644 index 00000000..40191016 --- /dev/null +++ b/v3prototype/Get-PSResourceValidations.ps1 @@ -0,0 +1,104 @@ +####################### +### Get-PSResource ### +####################### +### Getting Installed Modules ### +# Should get the module 'TestModule' +Get-PSResource 'TestModule' + +# Should get the module 'TestModule' +Get-PSResource -name 'TestModule' + +# Should get the module 'TestModule' +Get-PSResource 'TestModule' -Type 'Module' + +# Should get the module 'TestModule' +Get-PSResource 'TestModule' -Type 'Module', 'Script', 'Library' + +# Should get the modules 'TestModule1', 'TestModule2', 'TestModule3' +Get-PSResource 'TestModule1', 'TestModule2', 'TestModule3' + +# Should get the latest, non-prerelease version of the module 'TestModule' that is at least 1.5.0 +Get-PSResource 'TestModule' -MinimumVersion '1.5.0' + +# Should get the latest, non-prerelease version of the module 'TestModule' that is at most 1.5.0 +Get-PSResource 'TestModule' -MaximumVersion '1.5.0' + +# Should get the latest, non-prerelease version of the module 'TestModule' that is at least version 1.0.0 and at most 2.0.0 +Get-PSResource 'TestModule' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' + +# Should get version 1.5.0 (non-prerelease) of the module 'TestModule' +Get-PSResource 'TestModule' -RequiredVersion '1.5.0' + +# Should find all non-prerelease versions of the module 'TestModule' +Get-PSResource 'TestModule' -AllVersions + +# Should get the latest verison of 'TestModule', including prerelease versions +Get-PSResource 'TestModule' -Prerelease + + + +### Getting Installed Scripts ### +# Should get the script 'TestScript' +Get-PSResource 'TestScript' + +# Should get the script 'TestScript' +Get-PSResource -name 'TestScript' + +# Should get the module 'TestScript' +Get-PSResource 'TestScript' -Type 'Script' + +# Should get the module 'TestScript' +Get-PSResource 'TestScript' -Type 'Module', 'Script', 'Library' + +# Should get the scripts 'TestScript1', 'TestScript2', 'TestScript3' +Get-PSResource 'TestScript1', 'TestScript2', 'TestScript3' + +# Should get the latest, non-prerelease version of the script 'TestScript' that is at least 1.5.0 +Get-PSResource 'TestScript' -MinimumVersion '1.5.0' + +# Should get the latest, non-prerelease version of the script 'TestScript' that is at most 1.5.0 +Get-PSResource 'TestScript' -MaximumVersion '1.5.0' + +# Should get the latest, non-prerelease version of the script 'TestScript' that is at least version 1.0.0 and at most 2.0.0 +Get-PSResource 'TestScript' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' + +# Should get version 1.5.0 (non-prerelease) of the script 'TestScript' +Get-PSResource 'TestScript' -RequiredVersion '1.5.0' + +# Should find all non-prerelease versions of the module 'TestModule' +Get-PSResource 'TestModule' -AllVersions + +# Should get the latest verison of 'TestScript', including prerelease versions +Get-PSResource 'TestScript' -Prerelease + + +### Getting Installed Nupkgs ### +# Should get the nupkg 'TestNupkg' +Get-PSResource 'TestNupkg' + +# Should get the nupkg 'TestNupkg' +Get-PSResource 'TestNupkg' -Type 'Library' + +# Should get the nupkg 'TestNupkg' +Get-PSResource 'TestNupkg' -Type 'Module', 'Script', 'Library' + +# Should get the nupkgs 'TestNupkg1', 'TestNupkg2', 'TestNupkg3' +Get-PSResource 'TestNupkg1', 'TestNupkg2', 'TestNupkg3' + +# Should get the latest, non-prerelease version of the nupkg 'TestNupkg' that is at least 1.5.0 +Get-PSResource 'TestNupkg' -MinimumVersion '1.5.0' + +# Should get the latest, non-prerelease version of the nupkg 'TestNupkg' that is at most 1.5.0 +Get-PSResource 'TestNupkg' -MaximumVersion '1.5.0' + +# Should get the latest, non-prerelease version of the nupkg 'TestNupkg' that is at least version 1.0.0 and at most 2.0.0 +Get-PSResource 'TestNupkg' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' + +# Should get version 1.5.0 (non-prerelease) of the nupkg 'TestNupkg' +Get-PSResource 'TestNupkg' -RequiredVersion '1.5.0' + +# Should find all non-prerelease versions of the module 'TestModule' +Get-PSResource 'TestModule' -AllVersions + +# Should get the latest verison of 'TestNupkg', including prerelease versions +Get-PSResource 'TestNupkg' -Prerelease From a2db1ca8f0d68e757ca6ead7302fe624b28b87a6 Mon Sep 17 00:00:00 2001 From: Amber Erickson Date: Wed, 14 Aug 2019 20:14:15 -0700 Subject: [PATCH 10/11] Add Publish-PSResource cmd and validations --- v3prototype/Publish-PSResource.ps1 | 149 ++++++++++++++++++ v3prototype/Publish-PSResourceValidations.ps1 | 104 ++++++++++++ 2 files changed, 253 insertions(+) create mode 100644 v3prototype/Publish-PSResource.ps1 create mode 100644 v3prototype/Publish-PSResourceValidations.ps1 diff --git a/v3prototype/Publish-PSResource.ps1 b/v3prototype/Publish-PSResource.ps1 new file mode 100644 index 00000000..b7f0e898 --- /dev/null +++ b/v3prototype/Publish-PSResource.ps1 @@ -0,0 +1,149 @@ +function Publish-PSResource { + + [OutputType([void])] + [Cmdletbinding(SupportsShouldProcess = $true)] + Param + ( + # Specifies the name of the resource to be published. + [Parameter(Mandatory = $true, + ParameterSetName = "ModuleNameParameterSet", + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true)] + [ValidateNotNullOrEmpty()] + [string] + $Name, + + # Specifies the path to the resource that you want to publish. This parameter accepts the path to the folder that contains the resource. + # Specifies a path to one or more locations. Wildcards are permitted. The default location is the current directory (.). + [Parameter(Mandatory = $true, + ParameterSetName = "ModulePathParameterSet", + ValueFromPipelineByPropertyName = $true)] + [Parameter(Mandatory = $true, + ParameterSetName = 'ScriptPathParameterSet', + ValueFromPipelineByPropertyName = $true)] + [ValidateNotNullOrEmpty()] + [string] + $Path, + + # Specifies a path to one or more locations. Unlike the Path parameter, the value of the LiteralPath parameter is used exactly as entered. + # No characters are interpreted as wildcards. If the path includes escape characters, enclose them in single quotation marks. + # Single quotation marks tell PowerShell not to interpret any characters as escape sequences. + [Parameter(Mandatory = $true, + ParameterSetName = 'ModuleLiteralPathParameterSet', + ValueFromPipelineByPropertyName = $true)] + [Parameter(Mandatory = $true, + ParameterSetName = 'ScriptLiteralPathParameterSet', + ValueFromPipelineByPropertyName = $true)] + [Alias('PSPath')] + [ValidateNotNullOrEmpty()] + [string] + $LiteralPath, + + # Can be used to publish the a nupkg locally. + [Parameter(Mandatory = $true, + ParameterSetName = 'DestinationPathParameterSet', + ValueFromPipelineByPropertyName = $true)] + [ValidateNotNullOrEmpty()] + [string] + $DestinationPath, + + # Specifies the exact version of a single resource to publish. + [Parameter()] + [ValidateNotNullOrEmpty()] + [string] + $RequiredVersion, + + # Specifies the API key that you want to use to publish a module to the online gallery. + [Parameter()] + [ValidateNotNullOrEmpty()] + [string] + $NuGetApiKey, + + # Specifies the repository to publish to. + [Parameter()] + [ValidateNotNullOrEmpty()] + [string] + $Repository, + + # Specifies a user account that has rights to a specific repository. + [Parameter(ValueFromPipelineByPropertyName = $true)] + [PSCredential] + $Credential, + + # Specifies a string containing release notes or comments that you want to be available to users of this version of the resource. + [Parameter()] + [string[]] + $ReleaseNotes, + + # Adds one or more tags to the resource that you are publishing. + [Parameter()] + [ValidateNotNullOrEmpty()] + [string[]] + $Tags, + + # Specifies the URL of licensing terms for the resource you want to publish. + [Parameter()] + [ValidateNotNullOrEmpty()] + [Uri] + $LicenseUri, + + # Specifies the URL of an icon for the resource. + [Parameter()] + [ValidateNotNullOrEmpty()] + [Uri] + $IconUri, + + # Specifies the URL of a webpage about this project. + [Parameter()] + [ValidateNotNullOrEmpty()] + [Uri] + $ProjectUri, + + # Excludes files from a nuspec + [Parameter(ParameterSetName = "ModuleNameParameterSet")] + [ValidateNotNullOrEmpty()] + [string[]] + $Exclude, + + # Forces the command to run without asking for user confirmation. + [Parameter()] + [switch] + $Force, + + # Allows resources marked as prerelease to be published. + [Parameter()] + [switch] + $Prerelease, + + # Bypasses the default check that all dependencies are present. + [Parameter()] + [switch] + $SkipDependenciesCheck, + + # Specifies a nuspec file rather than relying on this module to produce one. + [Parameter()] + [switch] + $Nuspec + ) + + + begin { } + process { + if ($pscmdlet.ShouldProcess($Name)) { + if ($Name) { + # Publish module + Write-Verbose -message "Successfully published $Name" + } + elseif ($Path) { + # Publish resource + Write-Verbose -message "Successfully published $Path" + } + elseif ($LiteralPath) { + # Publish resource + Write-Verbose -message "Successfully published $LiteralPath" + } + } + } + + end { } +} diff --git a/v3prototype/Publish-PSResourceValidations.ps1 b/v3prototype/Publish-PSResourceValidations.ps1 new file mode 100644 index 00000000..3ee56089 --- /dev/null +++ b/v3prototype/Publish-PSResourceValidations.ps1 @@ -0,0 +1,104 @@ +########################## +### Publish-PSResource ### +########################## + +### Publish module ### +# Should publish the module 'TestModule' +Publish-PSResource -name 'TestModule' + +# Should publish the module 'TestModule' +Publish-PSResource 'TestModule' + +# Should publish the module 'TestModule' from the specified path +Publish-PSResource 'TestModule' -Path '.\*\somepath' + +# Should publish the module 'TestModule' from the specified literal path +Publish-PSResource 'TestModule' -LiteralPath '.' + +# Should publish the version 1.5.0 of the module 'TestModule' +Publish-PSResource 'TestModule' -RequiredVersion '1.5.0' + +# Should publish the lastest version of the module 'TestModule' even if it's a prerelease version +Publish-PSResource 'TestModule' -Prerelease + +# Should publish the version 1.5.0 of the module 'TestModule' +Publish-PSResource 'TestModule' -NuGetApiKey '1234567890' + +# Should publish the module 'TestModule' to the specified repository +Publish-PSResource 'TestModule' -Repository 'Repository' + +# Should publish the module 'TestModule' with release notes +Publish-PSResource 'TestModule' -ReleaseNotes 'Mock release notes.' + +# Should publish the module 'TestModule' with the tags 'Tag1', 'Tag2', 'Tag3' +Publish-PSResource 'TestModule' -Tags 'Tag1', 'Tag2', 'Tag3' + +# Should publish the module 'TestModule' with a specified license uri +Publish-PSResource 'TestModule' -LicenseUri 'www.licenseuri.com' + +# Should publish the module 'TestModule' with a specified icon uri +Publish-PSResource 'TestModule' -IconUri 'www.iconuri.com' + +# Should publish the module 'TestModule' with a specified projected uri +Publish-PSResource 'TestModule' -ProjectUri 'www.projecturi.com' + +# Should publish the module 'TestModule' and exclude the specified file from the nuspec. +Publish-PSResource 'TestModule' -Exclude 'some\path\file.ps1' + +# Should publish the module 'TestModule' without asking for user confirmation +Publish-PSResource 'TestModule' -Force + +# Should publish the module 'TestModule' without checking that all dependencies are present +Publish-PSResource 'TestModule' -SkipDependenciesCheck + +# Should publish the module 'TestModule' with a specified nuspec file +Publish-PSResource 'TestModule' -Nuspec '\path\to\file.nuspec' + + +# Should publish the nupkg 'TestNupkg' from the specified literal path +Publish-PSResource 'TestModule' -DestinationPath '.\TestNupkg.nupkg' + + + +### Publish Script ### +# Should publish the script 'TestScript' from the specified path +Publish-PSResource 'TestScript' -Path '.\*\TestScript.ps1' + +# Should publish the script 'TestScript' from the specified literal path +Publish-PSResource 'TestScript' -LiteralPath '.\TestScript.ps1' + +# Should publish the version 1.5.0 of the script 'TestScript' +Publish-PSResource 'TestScript' -RequiredVersion '1.5.0' + +# Should publish the lastest version of the script 'TestScript' even if it's a prerelease version +Publish-PSResource 'TestScript' -Prerelease + +# Should publish the version 1.5.0 of the script 'TestScript' +Publish-PSResource 'TestScript' -NuGetApiKey '1234567890' + +# Should publish the script 'TestScript' to the specified repository +Publish-PSResource 'TestScript' -Repository 'Repository' + +# Should publish the script 'TestScript' with release notes +Publish-PSResource 'TestScript' -ReleaseNotes 'Mock release notes.' + +# Should publish the script 'TestScript' with the tags 'Tag1', 'Tag2', 'Tag3' +Publish-PSResource 'TestScript' -Tags 'Tag1', 'Tag2', 'Tag3' + +# Should publish the script 'TestScript' with a specified license uri +Publish-PSResource 'TestScript' -LicenseUri 'www.licenseuri.com' + +# Should publish the script 'TestScript' with a specified icon uri +Publish-PSResource 'TestScript' -IconUri 'www.iconuri.com' + +# Should publish the script 'TestScript' with a specified projected uri +Publish-PSResource 'TestScript' -ProjectUri 'www.projecturi.com' + +# Should publish the script 'TestScript' without asking for user confirmation +Publish-PSResource 'TestScript' -Force + +# Should publish the script 'TestScript' without checking that all dependencies are present +Publish-PSResource 'TestScript' -SkipDependenciesCheck + +# Should publish the script 'TestScript' with a specified nuspec file +Publish-PSResource 'TestScript' -Nuspec '\path\to\file.nuspec' From f872284df2d6421698eb646a8e9d40aed91277fe Mon Sep 17 00:00:00 2001 From: Amber Erickson Date: Wed, 14 Aug 2019 20:55:20 -0700 Subject: [PATCH 11/11] Add Uninstall-PSResource cmd and validations --- v3prototype/Uninstall-PSResource.ps1 | 76 +++++++++++++++++++ .../Uninstall-PSResourceValidations.ps1 | 67 ++++++++++++++++ 2 files changed, 143 insertions(+) create mode 100644 v3prototype/Uninstall-PSResource.ps1 create mode 100644 v3prototype/Uninstall-PSResourceValidations.ps1 diff --git a/v3prototype/Uninstall-PSResource.ps1 b/v3prototype/Uninstall-PSResource.ps1 new file mode 100644 index 00000000..faec5720 --- /dev/null +++ b/v3prototype/Uninstall-PSResource.ps1 @@ -0,0 +1,76 @@ +function Uninstall-PSResource { + [OutputType([void])] + [cmdletbinding(SupportsShouldProcess = $true)] + Param + ( + # Specifies an array of resource names to uninstall. + [Parameter(Mandatory = $true, + ValueFromPipelineByPropertyName = $true, + Position = 0, + ParameterSetName = 'NameParameterSet')] + [ValidateNotNullOrEmpty()] + [String[]] + $Name, + + # Accepts a PSRepositoryItemInfo object. + # For example, output Get-InstalledModule to a variable and use that variable as the InputObject argument. + [Parameter(Mandatory = $true, + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, + Position = 0, + ParameterSetName = 'InputObject')] + [ValidateNotNull()] + [PSCustomObject[]] + $InputObject, + + # Specifies the minimum version of the resource to uninstall (can't be used with the RequiredVersion or AllVersions parameter). + [Parameter(ValueFromPipelineByPropertyName = $true, + ParameterSetName = 'NameParameterSet')] + [ValidateNotNull()] + [string] + $MinimumVersion, + + # Specifies the exact version number of the reource to uninstall (can't be used with the MinimumVersion, MaximumVersion, or AllVersions parameter). + [Parameter(ValueFromPipelineByPropertyName = $true, + ParameterSetName = 'NameParameterSet')] + [ValidateNotNull()] + [string] + $RequiredVersion, + + # Specifies the maximum, or newest, version of the resource to uninstall (can't be used with the RequiredVersion or AllVersions parameter). + [Parameter(ValueFromPipelineByPropertyName = $true, + ParameterSetName = 'NameParameterSet')] + [ValidateNotNull()] + [string] + $MaximumVersion, + + # Specifies that you want to include all available versions of a module (can't be used with the MinimumVersion, MaximumVersion, or RequiredVersion parameter). + [Parameter(ParameterSetName = 'NameParameterSet')] + [switch] + $AllVersions, + + # Uninstalls a resource without asking for user confirmation. + [Parameter()] + [Switch] + $Force, + + # Allows a prerelease version to be uninstalled. + [Parameter(ParameterSetName = 'NameParameterSet')] + [switch] + $Prerelease + ) + + begin { } + process { + foreach ($n in $Name) { + if ($pscmdlet.ShouldProcess($n)) { + + if (Get-PSResource $n) { + # Uninstall the resource + Write-Verbose -message "Successfully uninstalled $n" + } + } + } + } + end { } +} diff --git a/v3prototype/Uninstall-PSResourceValidations.ps1 b/v3prototype/Uninstall-PSResourceValidations.ps1 new file mode 100644 index 00000000..55116c04 --- /dev/null +++ b/v3prototype/Uninstall-PSResourceValidations.ps1 @@ -0,0 +1,67 @@ +############################ +### Uninstall-PSResource ### +############################ + +### Uninstalling Modules ### +# Should uninstall the module 'TestModule' +Uninstall-PSResource 'TestModule' + +# Should uninstall the module 'TestModule' +Uninstall-PSResource -name 'TestModule' + +# Should uninstall the modules 'TestModule1', 'TestModule2', 'TestModule3' +Uninstall-PSResource 'TestModule1', 'TestModule2', 'TestModule3' + +# Should uninstall the latest, non-prerelease version of the module 'TestModule' that is at least 1.5.0 +Uninstall-PSResource 'TestModule' -MinimumVersion '1.5.0' + +# Should uninstall the latest, non-prerelease version of the module 'TestModule' that is at most 1.5.0 +Uninstall-PSResource 'TestModule' -MaximumVersion '1.5.0' + +# Should uninstall the latest, non-prerelease version of the module 'TestModule' that is at least version 1.0.0 and at most 2.0.0 +Uninstall-PSResource 'TestModule' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' + +# Should uninstall version 1.5.0 (non-prerelease) of the module 'TestModule' +Uninstall-PSResource 'TestModule' -RequiredVersion '1.5.0' + +# Should uninstall all non-prerelease versions of the module 'TestModule' +Uninstall-PSResource 'TestModule' -AllVersions '1.5.0' + +# Should uninstall the latest verison of 'TestModule', including prerelease versions +Uninstall-PSResource 'TestModule' -Prerelease + +# Should uninstall the module 'TestModule' without asking for user confirmation +Uninstall-PSResource 'TestModule' -Force + + + +### Uninstalling Scripts ### +# Should uninstall the module 'TestScript' +Uninstall-PSResource 'TestScript' + +# Should uninstall the module 'TestScript' +Uninstall-PSResource -name 'TestScript' + +# Should uninstall the modules 'TestScript1', 'TestScript2', 'TestScript3' +Uninstall-PSResource 'TestScript1', 'TestScript2', 'TestScript3' + +# Should uninstall the latest, non-prerelease version of the module 'TestScript' that is at least 1.5.0 +Uninstall-PSResource 'TestScript' -MinimumVersion '1.5.0' + +# Should uninstall the latest, non-prerelease version of the module 'TestScript' that is at most 1.5.0 +Uninstall-PSResource 'TestScript' -MaximumVersion '1.5.0' + +# Should uninstall the latest, non-prerelease version of the module 'TestScript' that is at least version 1.0.0 and at most 2.0.0 +Uninstall-PSResource 'TestScript' -MinimumVersion '1.0.0' -MaximumVersion '2.0.0' + +# Should uninstall version 1.5.0 (non-prerelease) of the module 'TestScript' +Uninstall-PSResource 'TestScript' -RequiredVersion '1.5.0' + +# Should uninstall all non-prerelease versions of the module 'TestScript' +Uninstall-PSResource 'TestScript' -AllVersions '1.5.0' + +# Should uninstall the latest verison of 'TestScript', including prerelease versions +Uninstall-PSResource 'TestScript' -Prerelease + +# Should uninstall the module 'TestScript' without asking for user confirmation +Uninstall-PSResource 'TestScript' -Force