Vous ne pouvez pas appliquer le ScriptSourceLocation
paramètre pour NuGet
fournisseur. Considérons le script suivant :
$FindPackage_Cmdlet=Get-Command Find-Package
$FindPackage_Cmdlet.ParameterSets.Count ## 2
$FindPackage_Cmdlet.DefaultParameterSet ## $Null (not defined)
$FindPackage_Cmdlet.ParameterSets | ForEach-Object {
$aux = $_.Parameters.Name
$_.Name, ( 'ScriptSourceLocation' -in $aux ) -join ' ' ## NuGet False
## PowerShellGet True
$aux -join ' -' ## (parameters)
}
De l'autre côté, le ScriptSourceLocation
fonctionne pour PowerShellGet
fournisseur :
(Find-Package -ProviderName 'PowerShellGet' -ScriptSourceLocation 'https://www.powershellgallery.com/api/v2/items/psscript').Count
4956
Mise à jour
1. Veuillez noter que votre extrait de Get-Help Find-Package
semble être incomplète. Malheureusement, les deux modèles syntaxiques reposent sur [-ProviderName {NuGet | Bootstrap | PowerShellGet}]
:
SYNTAX
Find-Package [[-Name] <string[]>] [-IncludeDependencies] [-AllVersions] [-Source <string[]>] [-Credential <pscredential>] [-Proxy <uri>] [-ProxyCredential <pscredential>] [-RequiredVersion <string>] [-MinimumVersion <string>] [-MaximumVersion <string>] [-Force] [-ForceBootstrap]
[-ProviderName {NuGet | Bootstrap | PowerShellGet}] [-ConfigFile <string>] [-SkipValidate] [-Headers <string[]>] [-FilterOnTag <string[]>] [-Contains <string>] [-AllowPrereleaseVersions] [<CommonParameters>]
Find-Package [[-Name] <string[]>] [-IncludeDependencies] [-AllVersions] [-Source <string[]>] [-Credential <pscredential>] [-Proxy <uri>] [-ProxyCredential <pscredential>] [-RequiredVersion <string>] [-MinimumVersion <string>] [-MaximumVersion <string>][-Force] [-ForceBootstrap]
[-ProviderName {NuGet | Bootstrap | PowerShellGet}] [-AllowPrereleaseVersions] [-PackageManagementProvider <string>] [-PublishLocation <string>] [-ScriptSourceLocation <string>] [-ScriptPublishLocation <string>] [-Type {Module | Script | All}] [-Filter <string>] [-Tag <string[]>] [-Includes {DscResource | Cmdlet | Function | Workflow | RoleCapability}] [-DscResource <string[]>] [-RoleCapability <string[]>] [-Command <string[]>] [-AcceptLicense] [<CommonParameters>]
2. Testé en utilisant l'intellisense intégrée ( Visual Studio , PowerShell-ISE , PowerShell 6.2 , Windows PowerShell 5.1 ) :
ProviderName { Bootstrap | NuGet }
PS D:\PShell> Find-Package -ProviderName Bootstrap -Source
IncludeDependencies Force ErrorAction
AllVersions ForceBootstrap WarningAction
Source ConfigFile InformationAction
Credential SkipValidate ErrorVariable
Proxy Headers WarningVariable
ProxyCredential FilterOnTag InformationVariable
Name Contains OutVariable
RequiredVersion AllowPrereleaseVersions OutBuffer
MinimumVersion Verbose PipelineVariable
MaximumVersion Debug
[string[]] Source
Nom du fournisseur PowerShellGet
PS D:\PShell> Find-Package -ProviderName PowerShellGet -ScriptSourceLocation
IncludeDependencies PackageManagementProvider AcceptLicense
AllVersions PublishLocation Verbose
Source ScriptSourceLocation Debug
Credential ScriptPublishLocation ErrorAction
Proxy Type WarningAction
ProxyCredential Filter InformationAction
Name Tag ErrorVariable
RequiredVersion Includes WarningVariable
MinimumVersion DscResource InformationVariable
MaximumVersion RoleCapability OutVariable
Force AllowPrereleaseVersions OutBuffer
ForceBootstrap Command PipelineVariable
[string] ScriptSourceLocation
3. L'intellisense montre même quatre schémas syntaxiques différents dans PowerShell 5.1 :
activate intellisense here pressing Ctrl+Space
PS D:\PShell> Get-Package
Get-Package Get-PackageProvider Get-PackageSource
Get-Package [[-Name] <string[]>] [-RequiredVersion <string>] [-MinimumVersion <string>] [-MaximumVersion <string>] [-AllVersions] [-Force] [-ForceBootstrap] [-ProviderName <string[]>] [-Destination <string>] [-ExcludeVersion] [-Scope <string>] [-SkipDependencies] [<CommonParameters>]
Get-Package [[-Name] <string[]>] [-RequiredVersion <string>] [-MinimumVersion <string>] [-MaximumVersion <string>] [-AllVersions] [-Force] [-ForceBootstrap] [-ProviderName <string[]>] [-Scope <string>] [-PackageManagementProvider <string>] [-Type <string>] [-AllowClobber] [-SkipPublisherCheck] [-InstallUpdate] [-NoPathUpdate] [-AllowPrereleaseVersions] [<CommonParameters>]
Get-Package [[-Name] <string[]>] [-RequiredVersion <string>] [-MinimumVersion <string>] [-MaximumVersion <string>] [-AllVersions] [-Force] [-ForceBootstrap] [-ProviderName <string[]>] [-AdditionalArguments <string[]>] [<CommonParameters>]
Get-Package [[-Name] <string[]>] [-RequiredVersion <string>] [-MinimumVersion <string>] [-MaximumVersion <string>] [-AllVersions] [-Force] [-ForceBootstrap] [-ProviderName <string[]>] [-IncludeWindowsInstaller] [-IncludeSystemComponent] [<CommonParameters>]