Skip to content

The -Scope parameter for Export-Configuration has a parameterset (and it should not) #8

@Jaykul

Description

@Jaykul

We need to be able to specify a value for Export-Configuration -Scope regardless of ParameterSet (just like you can for Get-StoragePath).

Currently, it has it's ParameterSet to the ManualOverride set, so you can only use it when specifying the -Name and -Company by hand (as in the first example below).

I want all three of these to work:

Scenario: Specifying the scope when listing metadata
    Given a module with the name 'MyModule1' and the author 'MyCompany' with code like this
    """
    $Config = Import-Configuration -Company 'MyCompany' -Name MyModule1
    if(!$Config.ApiKey) {
        $Config =@{ ApiKey = "My Default API Key" }
        Export-Configuration $Config  -Company 'MyCompany' -Name MyModule1 -Scope Machine
    }
    """
    When the module is imported
    Then a settings file named Configuration.psd1 should exist in the Machine folder

Scenario: Specifying the scope when piping moduleinfo
    Given a module with the name 'MyModule1'
    When a user writes (something like) this
    """
    Get-Module MyModule1 | Export-Configuration @{ ApiKey = "MyApiKey" } -Scope Enterprise
    """
    Then a settings file named Configuration.psd1 should exist in the Enterprise folder

Scenario: Specifying the scope implicitly
    Given a module with the name 'MyModule1' and the author 'MyCompany' with code like this
    """
    function Set-ApiKey {
        param($ApiKey)
        $Config =@{ ApiKey = $ApiKey }
        Export-Configuration $Config -Scope Machine
    }
    """
   When I invoke Set-ApiKey "OurCorporateApiKey"
   Then a settings file named Configuration.psd1 should exist in the Machine folder

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions