Skip to content

Commit 45f3305

Browse files
author
Maddie Clayton
authored
Merge pull request #8239 from maddieclayton/process
Add Local scope to Enable-AzureRmAlias
2 parents cd80f53 + 056b15d commit 45f3305

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

src/Accounts/Accounts/AzureRmAlias/EnableAzureRmAlias.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ namespace Microsoft.Azure.Commands.Profile.AzureRmAlias
2525
/// <summary>
2626
/// Cmdlet to clear default options.
2727
/// </summary>
28-
[Cmdlet("Enable","AzureRmAlias", SupportsShouldProcess = true)]
28+
[Cmdlet("Enable", "AzureRmAlias", SupportsShouldProcess = true)]
2929
[OutputType(typeof(string))]
3030
public class EnableAzureRmAlias : AzureRMCmdlet
3131
{
32-
[Parameter(Mandatory = false, HelpMessage = "Indicates what scope aliases should be enabled for. Default is 'Process'")]
33-
[ValidateSet("Process", "CurrentUser", "LocalMachine")]
32+
[Parameter(Mandatory = false, HelpMessage = "Indicates what scope aliases should be enabled for. Default is 'Local'")]
33+
[ValidateSet("Local", "Process", "CurrentUser", "LocalMachine")]
3434
public string Scope { get; set; }
3535

3636
[Parameter(Mandatory = false, HelpMessage = "Indicates which modules to enable aliases for. If none are specified, default is all modules.")]
@@ -76,7 +76,15 @@ public void EnableLocalAliases(string[] modulesToEnable, Dictionary<string, obje
7676
foreach (var name in modulemapping.Keys)
7777
{
7878
// For every alias, add a pairing in the Alias provider
79-
SessionState.PSVariable.Set("Alias:" + modulemapping[name], name);
79+
if (Scope != null && string.Equals(Scope, "Process", StringComparison.OrdinalIgnoreCase))
80+
{
81+
this.InvokeCommand.InvokeScript("Set-Alias -Scope Global -Name " + modulemapping[name] + " -Value " + name);
82+
}
83+
else
84+
{
85+
SessionState.PSVariable.Set("Alias:" + modulemapping[name], name);
86+
}
87+
8088
if (PassThru)
8189
{
8290
WriteObject(modulemapping[name] + " : " + name);

src/Accounts/Accounts/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Add 'Local' Scope to Enable-AzureRmAlias
2122

2223
## Version 1.0.0
2324
* General availability of `Az.Accounts` module

src/Accounts/Accounts/help/Enable-AzureRmAlias.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
---
1+
---
22
external help file: Microsoft.Azure.PowerShell.Cmdlets.Accounts.dll-Help.xml
33
Module Name: Az.Accounts
44
online version: https://docs.microsoft.com/en-us/powershell/module/az.accounts/enable-azurermalias
@@ -86,13 +86,13 @@ Accept wildcard characters: False
8686
8787
### -Scope
8888
Indicates what scope aliases should be enabled for.
89-
Default is 'Process'
89+
Default is 'Local'
9090
9191
```yaml
9292
Type: System.String
9393
Parameter Sets: (All)
9494
Aliases:
95-
Accepted values: Process, CurrentUser, LocalMachine
95+
Accepted values: Local, Process, CurrentUser, LocalMachine
9696

9797
Required: False
9898
Position: Named

0 commit comments

Comments
 (0)