diff --git a/src/Authentication/Authentication/Cmdlets/ConnectGraph.cs b/src/Authentication/Authentication/Cmdlets/ConnectMgGraph.cs
similarity index 90%
rename from src/Authentication/Authentication/Cmdlets/ConnectGraph.cs
rename to src/Authentication/Authentication/Cmdlets/ConnectMgGraph.cs
index 5a224425a30..e8bb9ea125b 100644
--- a/src/Authentication/Authentication/Cmdlets/ConnectGraph.cs
+++ b/src/Authentication/Authentication/Cmdlets/ConnectMgGraph.cs
@@ -17,8 +17,9 @@ namespace Microsoft.Graph.PowerShell.Authentication.Cmdlets
using System.Net;
using System.Globalization;
- [Cmdlet(VerbsCommunications.Connect, "Graph", DefaultParameterSetName = Constants.UserParameterSet)]
- public class ConnectGraph : PSCmdlet, IModuleAssemblyInitializer, IModuleAssemblyCleanup
+ [Cmdlet(VerbsCommunications.Connect, "MgGraph", DefaultParameterSetName = Constants.UserParameterSet)]
+ [Alias("Connect-Graph")]
+ public class ConnectMgGraph : PSCmdlet, IModuleAssemblyInitializer, IModuleAssemblyCleanup
{
[Parameter(ParameterSetName = Constants.UserParameterSet,
Position = 1,
@@ -29,11 +30,13 @@ public class ConnectGraph : PSCmdlet, IModuleAssemblyInitializer, IModuleAssembl
Position = 1,
Mandatory = true,
HelpMessage = "The client id of your application.")]
+ [Alias("AppId")]
public string ClientId { get; set; }
[Parameter(ParameterSetName = Constants.AppParameterSet,
Position = 2,
HelpMessage = "The name of your certificate. The Certificate will be retrieved from the current user's certificate store.")]
+ [Alias("CertificateSubject")]
public string CertificateName { get; set; }
[Parameter(ParameterSetName = Constants.AppParameterSet,
@@ -85,7 +88,8 @@ protected override void ProcessRecord()
TimeSpan authTimeout = new TimeSpan(0, 0, Constants.MaxDeviceCodeTimeOut);
cancellationTokenSource = new CancellationTokenSource(authTimeout);
authContext.AuthType = AuthenticationType.Delegated;
- authContext.Scopes = Scopes ?? new string[] { "User.Read" };
+ string[] processedScopes = ProcessScopes(Scopes);
+ authContext.Scopes = processedScopes.Length == 0 ? new string[] { "User.Read" } : processedScopes;
// Default to CurrentUser but allow the customer to change this via `ContextScope` param.
authContext.ContextScope = this.IsParameterBound(nameof(ContextScope)) ? ContextScope : ContextScope.CurrentUser;
}
@@ -190,6 +194,31 @@ protected override void StopProcessing()
base.StopProcessing();
}
+ ///
+ /// Processes user provided scopes by removing whitespace and splitting comma separated scopes.
+ ///
+ /// An array of scopes.
+ /// A formated array of scopes.
+ private string[] ProcessScopes(string[] scopes)
+ {
+ if (scopes == null)
+ {
+ return new string[0];
+ }
+
+ List formatedScopes = new List();
+ foreach (string scope in scopes)
+ {
+ string[] cleanScopes = scope.Split(',')
+ .Select(s => s.Trim())
+ .Where(s => !string.IsNullOrWhiteSpace(s))
+ .ToArray();
+
+ formatedScopes.AddRange(cleanScopes);
+ }
+ return formatedScopes.ToArray();
+ }
+
private void ValidateParameters()
{
switch (ParameterSetName)
diff --git a/src/Authentication/Authentication/Cmdlets/DisconnectGraph.cs b/src/Authentication/Authentication/Cmdlets/DisconnectMgGraph.cs
similarity index 90%
rename from src/Authentication/Authentication/Cmdlets/DisconnectGraph.cs
rename to src/Authentication/Authentication/Cmdlets/DisconnectMgGraph.cs
index 085c9b5f34e..8e38062da9b 100644
--- a/src/Authentication/Authentication/Cmdlets/DisconnectGraph.cs
+++ b/src/Authentication/Authentication/Cmdlets/DisconnectMgGraph.cs
@@ -6,8 +6,9 @@ namespace Microsoft.Graph.PowerShell.Authentication.Cmdlets
using Microsoft.Graph.PowerShell.Authentication.Helpers;
using System;
using System.Management.Automation;
- [Cmdlet(VerbsCommunications.Disconnect, "Graph")]
- public class DisconnectGraph : PSCmdlet
+ [Cmdlet(VerbsCommunications.Disconnect, "MgGraph")]
+ [Alias("Disconnect-Graph")]
+ public class DisconnectMgGraph : PSCmdlet
{
protected override void BeginProcessing()
{
diff --git a/src/Authentication/Authentication/Cmdlets/InvokeGraphRequest.cs b/src/Authentication/Authentication/Cmdlets/InvokeMgGraphRequest.cs
similarity index 99%
rename from src/Authentication/Authentication/Cmdlets/InvokeGraphRequest.cs
rename to src/Authentication/Authentication/Cmdlets/InvokeMgGraphRequest.cs
index 9f66df3db5b..7f4d0b3c9dc 100644
--- a/src/Authentication/Authentication/Cmdlets/InvokeGraphRequest.cs
+++ b/src/Authentication/Authentication/Cmdlets/InvokeMgGraphRequest.cs
@@ -22,14 +22,15 @@
namespace Microsoft.Graph.PowerShell.Authentication.Cmdlets
{
- [Cmdlet(VerbsLifecycle.Invoke, "GraphRequest", DefaultParameterSetName = Constants.UserParameterSet)]
- public class InvokeGraphRequest : PSCmdlet
+ [Cmdlet(VerbsLifecycle.Invoke, "MgGraphRequest", DefaultParameterSetName = Constants.UserParameterSet)]
+ [Alias("Invoke-GraphRequest")]
+ public class InvokeMgGraphRequest : PSCmdlet
{
private readonly CancellationTokenSource _cancellationTokenSource;
private readonly InvokeGraphRequestUserAgent _graphRequestUserAgent;
private string _originalFilePath;
- public InvokeGraphRequest()
+ public InvokeMgGraphRequest()
{
_cancellationTokenSource = new CancellationTokenSource();
_graphRequestUserAgent = new InvokeGraphRequestUserAgent(this);
diff --git a/src/Authentication/Authentication/Helpers/HttpHelpers.cs b/src/Authentication/Authentication/Helpers/HttpHelpers.cs
index c030452fd68..3b29c5a4c2d 100644
--- a/src/Authentication/Authentication/Helpers/HttpHelpers.cs
+++ b/src/Authentication/Authentication/Helpers/HttpHelpers.cs
@@ -17,7 +17,7 @@ namespace Microsoft.Graph.PowerShell.Authentication.Helpers
public static class HttpHelpers
{
/// The version for current assembly.
- private static AssemblyName AssemblyInfo = typeof(ConnectGraph).GetTypeInfo().Assembly.GetName();
+ private static AssemblyName AssemblyInfo = typeof(ConnectMgGraph).GetTypeInfo().Assembly.GetName();
/// The value for the Auth module version header.
private static string AuthModuleVersionHeaderValue =
diff --git a/src/Authentication/Authentication/Helpers/PathUtils.cs b/src/Authentication/Authentication/Helpers/PathUtils.cs
index 716aa4cdd87..13d8c9ed449 100644
--- a/src/Authentication/Authentication/Helpers/PathUtils.cs
+++ b/src/Authentication/Authentication/Helpers/PathUtils.cs
@@ -13,7 +13,7 @@ namespace Microsoft.Graph.PowerShell.Authentication.Helpers
///
internal static class PathUtils
{
- public static string ResolveFilePath(string filePath, InvokeGraphRequest command, bool isLiteralPath)
+ public static string ResolveFilePath(string filePath, InvokeMgGraphRequest command, bool isLiteralPath)
{
string path = null;
try
diff --git a/src/Authentication/Authentication/Helpers/StreamHelper.cs b/src/Authentication/Authentication/Helpers/StreamHelper.cs
index 7329861cdb3..0a0a042c278 100644
--- a/src/Authentication/Authentication/Helpers/StreamHelper.cs
+++ b/src/Authentication/Authentication/Helpers/StreamHelper.cs
@@ -79,7 +79,7 @@ internal static string StreamToString(this Stream stream, Encoding encoding)
}
internal static void SaveStreamToFile(this Stream baseResponseStream, string filePath,
- InvokeGraphRequest invokeGraphRequest, CancellationToken token)
+ InvokeMgGraphRequest invokeGraphRequest, CancellationToken token)
{
// If the web cmdlet should resume, append the file instead of overwriting.
const FileMode fileMode = FileMode.Create;
diff --git a/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1 b/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1
index fe97302236b..c438de46e4a 100644
--- a/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1
+++ b/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1
@@ -72,14 +72,14 @@ FormatsToProcess = './Microsoft.Graph.Authentication.format.ps1xml'
FunctionsToExport = @()
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
-CmdletsToExport = 'Connect-Graph', 'Disconnect-Graph', 'Get-MgContext', 'Get-MgProfile',
- 'Select-MgProfile', 'Invoke-GraphRequest'
+CmdletsToExport = 'Connect-MgGraph', 'Disconnect-MgGraph', 'Get-MgContext', 'Get-MgProfile',
+ 'Select-MgProfile', 'Invoke-MgGraphRequest'
# Variables to export from this module
# VariablesToExport = @()
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
-AliasesToExport = @()
+AliasesToExport = @('Connect-Graph', 'Disconnect-Graph', 'Invoke-GraphRequest')
# DSC resources to export from this module
# DscResourcesToExport = @()