@@ -25,12 +25,12 @@ namespace Microsoft.Azure.Commands.Profile.AzureRmAlias
25
25
/// <summary>
26
26
/// Cmdlet to clear default options.
27
27
/// </summary>
28
- [ Cmdlet ( "Enable" , "AzureRmAlias" , SupportsShouldProcess = true ) ]
28
+ [ Cmdlet ( "Enable" , "AzureRmAlias" , SupportsShouldProcess = true ) ]
29
29
[ OutputType ( typeof ( string ) ) ]
30
30
public class EnableAzureRmAlias : AzureRMCmdlet
31
31
{
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" ) ]
34
34
public string Scope { get ; set ; }
35
35
36
36
[ 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
76
76
foreach ( var name in modulemapping . Keys )
77
77
{
78
78
// 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
+
80
88
if ( PassThru )
81
89
{
82
90
WriteObject ( modulemapping [ name ] + " : " + name ) ;
0 commit comments