From 6b4b3491da1baa89eaee5c35818febd07a9af8b6 Mon Sep 17 00:00:00 2001 From: Timothy Wamalwa Date: Tue, 21 Jun 2022 13:52:16 +0300 Subject: [PATCH 01/16] Documenting Add-MgEnvironment and Get_MgEnvironment --- README.md | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cf533f2d67d..311531815a0 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,11 @@ There is a set of samples in the `samples` folder to help in getting started wit ## Usage -1. Authentication +* [Authentication](./README.md#authentication) + +* [Environment](./README.md#environment) + +## Authentication The SDK supports two types of authentication: delegated access and app-only access. - Delegated access. @@ -105,6 +109,65 @@ There is a set of samples in the `samples` folder to help in getting started wit Disconnect-MgGraph ``` +## Environment + + The SDK supports addition, setting, querying and removal of microsoft graph environemnts. + - Add Microsoft Graph Environment. + + - Delegated access + + ``` powershell + # Using interactive authentication. + $TestEnv = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' + Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" -Environment $TestEnv.Name + ``` + or + + ``` powershell + # Using device code flow. + $TestEnv = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' + Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" -UseDeviceAuthentication -Environment $TestEnv.Name + ``` + or + + # Using your own access token. + $TestEnv = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' + Connect-MgGraph -AccessToken $AccessToken -Environment $TestEnv.Name + ``` + - App-only access via Client Credential with a certificate. + + ``` powershell + # Using -CertificateThumbprint. + $TestEnv = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' + Connect-MgGraph -TenantId "YOUR_TENANT_ID" -CertificateThumbprint "YOUR_CERT_THUMBPRINT" -ClientId "YOUR_APP_ID" -Environment $TestEnv.Name + ``` + or + + ``` powershell + # Using -CertificateName. + $TestEnv = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' + Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -CertificateName "YOUR_CERT_SUBJECT" -Environment $TestEnv.Name + ``` + or + + ``` powershell + # Using -Certificate + $TestEnv = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' + $Cert = Get-ChildItem Cert:\LocalMachine\My\$CertThumbprint + Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -Certificate $Cert -Environment $TestEnv.Name + ``` + - Get Microsoft Graph Environment. + + A collection of environments will be returned by using the `Get-MgEnvironment` command. Display on the console will be inform of a table with the below details. + + Name | AzureADEndpoint | GraphEndpoint | Type + ---- --------------- ------------- ---- + + ``` powershell + Get-MgEnvironment + ``` + + ## API Version By default, the SDK uses the Microsoft Graph REST API v1.0. You can change this by using the `Select-MgProfile` command. This reloads all modules and only loads commands that call beta endpoint. From fbd21ced080ee12179d4eb27f9257f4f7233d120 Mon Sep 17 00:00:00 2001 From: Timothy Wamalwa Date: Tue, 21 Jun 2022 14:17:16 +0300 Subject: [PATCH 02/16] Rectified indentation --- README.md | 165 +++++++++++++++++++++++++++--------------------------- 1 file changed, 84 insertions(+), 81 deletions(-) diff --git a/README.md b/README.md index 311531815a0..f035608781e 100644 --- a/README.md +++ b/README.md @@ -33,69 +33,71 @@ There is a set of samples in the `samples` folder to help in getting started wit * [Authentication](./README.md#authentication) +* [Users](./README.md#users) + * [Environment](./README.md#environment) ## Authentication +The SDK supports two types of authentication: delegated access and app-only access. +- Delegated access. - The SDK supports two types of authentication: delegated access and app-only access. - - Delegated access. - - ``` powershell - # Using interactive authentication. - Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" - ``` + ``` powershell + # Using interactive authentication. + Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" + ``` - or + or - ``` powershell - # Using device code flow. - Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" -UseDeviceAuthentication - ``` + ``` powershell + # Using device code flow. + Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" -UseDeviceAuthentication + ``` - or + or - ``` powershell - # Using your own access token. - Connect-MgGraph -AccessToken $AccessToken - ``` + ``` powershell + # Using your own access token. + Connect-MgGraph -AccessToken $AccessToken + ``` - - App-only access via Client Credential with a certificate. +- App-only access via Client Credential with a certificate. - The certificate will be loaded from `Cert:\CurrentUser\My\` store when `-CertificateThumbprint` or `-CertificateName` is specified. Ensure the certificate is present in the store before calling `Connect-MgGraph`. + The certificate will be loaded from `Cert:\CurrentUser\My\` store when `-CertificateThumbprint` or `-CertificateName` is specified. Ensure the certificate is present in the store before calling `Connect-MgGraph`. - ``` powershell - # Using -CertificateThumbprint - Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -CertificateThumbprint "YOUR_CERT_THUMBPRINT" - ``` + ``` powershell + # Using -CertificateThumbprint + Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -CertificateThumbprint "YOUR_CERT_THUMBPRINT" + ``` - or + or - ``` powershell - # Using -CertificateName - Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -CertificateName "YOUR_CERT_SUBJECT" - ``` + ``` powershell + # Using -CertificateName + Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -CertificateName "YOUR_CERT_SUBJECT" + ``` - or + or - ``` powershell - # Using -Certificate - $Cert = Get-ChildItem Cert:\LocalMachine\My\$CertThumbprint - Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -Certificate $Cert - ``` + ``` powershell + # Using -Certificate + $Cert = Get-ChildItem Cert:\LocalMachine\My\$CertThumbprint + Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -Certificate $Cert + ``` +## Users -2. List users in your tenant. +1. List users in your tenant. ``` powershell Get-MgUser -Top 10 -Property Id, DisplayName, BusinessPhones | Format-Table Id, DisplayName, BusinessPhones ``` -3. Filter a user in your tenant. +2. Filter a user in your tenant. ``` powershell $user = Get-MgUser -Filter "displayName eq 'Megan Bowen'" ``` -4. Create a new app registration. +3. Create a new app registration. ``` powershell New-MgApplication -DisplayName "ScriptedGraphPSApp" ` @@ -103,7 +105,7 @@ There is a set of samples in the `samples` folder to help in getting started wit -Web @{ RedirectUris = "https://localhost"} ``` -5. Sign out of the current logged-in context i.e. app only or delegated access. +4. Sign out of the current logged-in context i.e. app only or delegated access. ``` powershell Disconnect-MgGraph @@ -111,51 +113,52 @@ There is a set of samples in the `samples` folder to help in getting started wit ## Environment - The SDK supports addition, setting, querying and removal of microsoft graph environemnts. - - Add Microsoft Graph Environment. +The SDK supports addition, setting, querying and removal of microsoft graph environemnts. +- Add Microsoft Graph Environment. - - Delegated access - - ``` powershell - # Using interactive authentication. - $TestEnv = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' - Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" -Environment $TestEnv.Name - ``` - or - - ``` powershell - # Using device code flow. - $TestEnv = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' - Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" -UseDeviceAuthentication -Environment $TestEnv.Name - ``` - or - - # Using your own access token. - $TestEnv = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' - Connect-MgGraph -AccessToken $AccessToken -Environment $TestEnv.Name - ``` - - App-only access via Client Credential with a certificate. + - Delegated access + + ``` powershell + # Using interactive authentication. + $TestEnv = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' + Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" -Environment $TestEnv.Name + ``` + or + + ``` powershell + # Using device code flow. + $TestEnv = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' + Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" -UseDeviceAuthentication -Environment $TestEnv.Name + ``` + or + + ``` powershell + # Using your own access token. + $TestEnv = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' + Connect-MgGraph -AccessToken $AccessToken -Environment $TestEnv.Name + ``` + - App-only access via Client Credential with a certificate. - ``` powershell - # Using -CertificateThumbprint. - $TestEnv = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' - Connect-MgGraph -TenantId "YOUR_TENANT_ID" -CertificateThumbprint "YOUR_CERT_THUMBPRINT" -ClientId "YOUR_APP_ID" -Environment $TestEnv.Name - ``` - or - - ``` powershell - # Using -CertificateName. - $TestEnv = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' - Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -CertificateName "YOUR_CERT_SUBJECT" -Environment $TestEnv.Name - ``` - or - - ``` powershell - # Using -Certificate - $TestEnv = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' - $Cert = Get-ChildItem Cert:\LocalMachine\My\$CertThumbprint - Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -Certificate $Cert -Environment $TestEnv.Name - ``` + ``` powershell + # Using -CertificateThumbprint. + $TestEnv = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' + Connect-MgGraph -TenantId "YOUR_TENANT_ID" -CertificateThumbprint "YOUR_CERT_THUMBPRINT" -ClientId "YOUR_APP_ID" -Environment $TestEnv.Name + ``` + or + + ``` powershell + # Using -CertificateName. + $TestEnv = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' + Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -CertificateName "YOUR_CERT_SUBJECT" -Environment $TestEnv.Name + ``` + or + + ``` powershell + # Using -Certificate + $TestEnv = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' + $Cert = Get-ChildItem Cert:\LocalMachine\My\$CertThumbprint + Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -Certificate $Cert -Environment $TestEnv.Name + ``` - Get Microsoft Graph Environment. A collection of environments will be returned by using the `Get-MgEnvironment` command. Display on the console will be inform of a table with the below details. From ff070d2fb21a4ef9bfaf3a9a842136efc86fbea5 Mon Sep 17 00:00:00 2001 From: Timothy Wamalwa Date: Tue, 21 Jun 2022 15:24:04 +0300 Subject: [PATCH 03/16] Updated readme document to have Set-mgEnvironment and Remove-MgEnvironment --- autorest.powershell | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autorest.powershell b/autorest.powershell index c2f544bdca3..0132d230221 160000 --- a/autorest.powershell +++ b/autorest.powershell @@ -1 +1 @@ -Subproject commit c2f544bdca37d58da15bb36cf39248f99fecb2a2 +Subproject commit 0132d230221f3a3c422f800db487c118965b195a From e094de2eb1f8b98fb3fde7f1943d95da26daa1f2 Mon Sep 17 00:00:00 2001 From: Timothy Wamalwa Date: Tue, 21 Jun 2022 15:25:56 +0300 Subject: [PATCH 04/16] Rectified grammatical errors --- README.md | 49 +++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index f035608781e..631b6318d5d 100644 --- a/README.md +++ b/README.md @@ -113,62 +113,75 @@ The SDK supports two types of authentication: delegated access and app-only acce ## Environment -The SDK supports addition, setting, querying and removal of microsoft graph environemnts. +The SDK supports managing of cloud environments through `Get-MgEnvironment`, `Set-MgEnvironment`, `Add-MgEnvironment`, and `remove-MgEnvironment`. - Add Microsoft Graph Environment. - + + A `user-defined` environments type is added to microsoft graph and used to connect to graph. - Delegated access ``` powershell # Using interactive authentication. - $TestEnv = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' - Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" -Environment $TestEnv.Name + $Env = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' + Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" -Environment $Env.Name ``` or ``` powershell # Using device code flow. - $TestEnv = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' - Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" -UseDeviceAuthentication -Environment $TestEnv.Name + $Env = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' + Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" -UseDeviceAuthentication -Environment $Env.Name ``` or ``` powershell # Using your own access token. - $TestEnv = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' - Connect-MgGraph -AccessToken $AccessToken -Environment $TestEnv.Name + $Env = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' + Connect-MgGraph -AccessToken $AccessToken -Environment $Env.Name ``` - App-only access via Client Credential with a certificate. ``` powershell # Using -CertificateThumbprint. - $TestEnv = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' - Connect-MgGraph -TenantId "YOUR_TENANT_ID" -CertificateThumbprint "YOUR_CERT_THUMBPRINT" -ClientId "YOUR_APP_ID" -Environment $TestEnv.Name + $Env = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' + Connect-MgGraph -TenantId "YOUR_TENANT_ID" -CertificateThumbprint "YOUR_CERT_THUMBPRINT" -ClientId "YOUR_APP_ID" -Environment $Env.Name ``` or ``` powershell # Using -CertificateName. - $TestEnv = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' - Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -CertificateName "YOUR_CERT_SUBJECT" -Environment $TestEnv.Name + $Env = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' + Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -CertificateName "YOUR_CERT_SUBJECT" -Environment $Env.Name ``` or ``` powershell # Using -Certificate - $TestEnv = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' + $Env = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' $Cert = Get-ChildItem Cert:\LocalMachine\My\$CertThumbprint - Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -Certificate $Cert -Environment $TestEnv.Name + Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -Certificate $Cert -Environment $Env.Name ``` - Get Microsoft Graph Environment. - A collection of environments will be returned by using the `Get-MgEnvironment` command. Display on the console will be inform of a table with the below details. - - Name | AzureADEndpoint | GraphEndpoint | Type - ---- --------------- ------------- ---- + A collection of environments will be returned by using the `Get-MgEnvironment` command. ``` powershell Get-MgEnvironment ``` + - Set Microsoft Graph Environment. + + `Set-MgEnvironment` command adds a `user-defined` environment type using the existing microsoft graph session + + ``` powershell + Set-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT + ``` + - Set Microsoft Graph Environment. + + `Remove-MgEnvironment` command removes an environment initially set by a user, from the existing microsoft graph session. It eventually defaults to Global. + + ``` powershell + Remove-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' + ``` + ## API Version From 9a6b4fdb9cbab56995ac58342188f2cc23555670 Mon Sep 17 00:00:00 2001 From: Timothy Wamalwa Date: Tue, 21 Jun 2022 15:32:26 +0300 Subject: [PATCH 05/16] Renamed environment title --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 631b6318d5d..2b083bb16f8 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ There is a set of samples in the `samples` folder to help in getting started wit * [Users](./README.md#users) -* [Environment](./README.md#environment) +* [Cloud Environment](./README.md#environment) ## Authentication The SDK supports two types of authentication: delegated access and app-only access. @@ -111,9 +111,9 @@ The SDK supports two types of authentication: delegated access and app-only acce Disconnect-MgGraph ``` -## Environment +## Cloud Environment -The SDK supports managing of cloud environments through `Get-MgEnvironment`, `Set-MgEnvironment`, `Add-MgEnvironment`, and `remove-MgEnvironment`. +The SDK supports managing of cloud environments through `Get-MgEnvironment`, `Set-MgEnvironment`, `Add-MgEnvironment`, and `remove-MgEnvironment` commands - Add Microsoft Graph Environment. A `user-defined` environments type is added to microsoft graph and used to connect to graph. From 38256ec4a12ba7b97858404156172237a713911f Mon Sep 17 00:00:00 2001 From: Timothy Wamalwa Date: Tue, 21 Jun 2022 15:41:07 +0300 Subject: [PATCH 06/16] Updated descriptions --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2b083bb16f8..2e78593f3b4 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ The SDK supports two types of authentication: delegated access and app-only acce The SDK supports managing of cloud environments through `Get-MgEnvironment`, `Set-MgEnvironment`, `Add-MgEnvironment`, and `remove-MgEnvironment` commands - Add Microsoft Graph Environment. - A `user-defined` environments type is added to microsoft graph and used to connect to graph. + A `user-defined` environment type is added and the name passed as `-Environment` parameter on the `Connect-Mgraph` command for user to be able to switch to a cloud of choice. - Delegated access ``` powershell @@ -169,7 +169,7 @@ The SDK supports managing of cloud environments through `Get-MgEnvironment`, `Se ``` - Set Microsoft Graph Environment. - `Set-MgEnvironment` command adds a `user-defined` environment type using the existing microsoft graph session + `Set-MgEnvironment` command switches to a `user-defined` environment type using the existing microsoft graph session ``` powershell Set-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT From 662a2ebaa6069d714db4899b1093c9b82bbcd6c3 Mon Sep 17 00:00:00 2001 From: Timothy Wamalwa Date: Tue, 21 Jun 2022 15:44:06 +0300 Subject: [PATCH 07/16] Updated cloud links --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2e78593f3b4..114646b95ba 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ There is a set of samples in the `samples` folder to help in getting started wit * [Users](./README.md#users) -* [Cloud Environment](./README.md#environment) +* [Cloud Environment](./README.md#cloud-environment) ## Authentication The SDK supports two types of authentication: delegated access and app-only access. From 31fb1b54cfee61f207b19ef8c136c14888b64411 Mon Sep 17 00:00:00 2001 From: Timothy Wamalwa Date: Tue, 21 Jun 2022 15:46:47 +0300 Subject: [PATCH 08/16] Updated headings for cloud descritions --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 114646b95ba..16a023dc2f3 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ The SDK supports two types of authentication: delegated access and app-only acce ## Cloud Environment The SDK supports managing of cloud environments through `Get-MgEnvironment`, `Set-MgEnvironment`, `Add-MgEnvironment`, and `remove-MgEnvironment` commands -- Add Microsoft Graph Environment. +- Add Environment. A `user-defined` environment type is added and the name passed as `-Environment` parameter on the `Connect-Mgraph` command for user to be able to switch to a cloud of choice. - Delegated access @@ -160,7 +160,7 @@ The SDK supports managing of cloud environments through `Get-MgEnvironment`, `Se $Cert = Get-ChildItem Cert:\LocalMachine\My\$CertThumbprint Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -Certificate $Cert -Environment $Env.Name ``` - - Get Microsoft Graph Environment. + - Get Environment. A collection of environments will be returned by using the `Get-MgEnvironment` command. @@ -174,7 +174,7 @@ The SDK supports managing of cloud environments through `Get-MgEnvironment`, `Se ``` powershell Set-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT ``` - - Set Microsoft Graph Environment. + - Remove Environment. `Remove-MgEnvironment` command removes an environment initially set by a user, from the existing microsoft graph session. It eventually defaults to Global. From fb936169c0b5ba0de435415178033574c5813f63 Mon Sep 17 00:00:00 2001 From: Timothy Wamalwa Date: Tue, 21 Jun 2022 16:11:05 +0300 Subject: [PATCH 09/16] Separated the documentation into descriptive files --- .../Applications/Application.md | 9 ++ .../CloudEnvironment/CloudEnvironment.md | 70 ++++++++++++ CmdletsDescription/Users/Users.md | 13 +++ README.md | 102 +----------------- 4 files changed, 96 insertions(+), 98 deletions(-) create mode 100644 CmdletsDescription/Applications/Application.md create mode 100644 CmdletsDescription/CloudEnvironment/CloudEnvironment.md create mode 100644 CmdletsDescription/Users/Users.md diff --git a/CmdletsDescription/Applications/Application.md b/CmdletsDescription/Applications/Application.md new file mode 100644 index 00000000000..dd7cbc0c6a8 --- /dev/null +++ b/CmdletsDescription/Applications/Application.md @@ -0,0 +1,9 @@ +## Applications + +1. Create a new app registration. + + ``` powershell + New-MgApplication -DisplayName "ScriptedGraphPSApp" ` + -SignInAudience "AzureADMyOrg" ` + -Web @{ RedirectUris = "https://localhost"} + ``` \ No newline at end of file diff --git a/CmdletsDescription/CloudEnvironment/CloudEnvironment.md b/CmdletsDescription/CloudEnvironment/CloudEnvironment.md new file mode 100644 index 00000000000..70f59a328f1 --- /dev/null +++ b/CmdletsDescription/CloudEnvironment/CloudEnvironment.md @@ -0,0 +1,70 @@ +## Cloud Environment + +The SDK supports managing of cloud environments through `Get-MgEnvironment`, `Set-MgEnvironment`, `Add-MgEnvironment`, and `remove-MgEnvironment` commands +- Add Environment. + + A `user-defined` environment type is added and the name passed as `-Environment` parameter on the `Connect-Mgraph` command for user to be able to switch to a cloud of choice. + - Delegated access + + ``` powershell + # Using interactive authentication. + $Env = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' + Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" -Environment $Env.Name + ``` + or + + ``` powershell + # Using device code flow. + $Env = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' + Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" -UseDeviceAuthentication -Environment $Env.Name + ``` + or + + ``` powershell + # Using your own access token. + $Env = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' + Connect-MgGraph -AccessToken $AccessToken -Environment $Env.Name + ``` + - App-only access via Client Credential with a certificate. + + ``` powershell + # Using -CertificateThumbprint. + $Env = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' + Connect-MgGraph -TenantId "YOUR_TENANT_ID" -CertificateThumbprint "YOUR_CERT_THUMBPRINT" -ClientId "YOUR_APP_ID" -Environment $Env.Name + ``` + or + + ``` powershell + # Using -CertificateName. + $Env = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' + Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -CertificateName "YOUR_CERT_SUBJECT" -Environment $Env.Name + ``` + or + + ``` powershell + # Using -Certificate + $Env = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' + $Cert = Get-ChildItem Cert:\LocalMachine\My\$CertThumbprint + Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -Certificate $Cert -Environment $Env.Name + ``` + - Get Environment. + + A collection of environments will be returned by using the `Get-MgEnvironment` command. + + ``` powershell + Get-MgEnvironment + ``` + - Set Microsoft Graph Environment. + + `Set-MgEnvironment` command switches to a `user-defined` environment type using the existing microsoft graph session + + ``` powershell + Set-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT + ``` + - Remove Environment. + + `Remove-MgEnvironment` command removes an environment initially set by a user, from the existing microsoft graph session. It eventually defaults to Global. + + ``` powershell + Remove-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' + ``` \ No newline at end of file diff --git a/CmdletsDescription/Users/Users.md b/CmdletsDescription/Users/Users.md new file mode 100644 index 00000000000..815fe1dfe38 --- /dev/null +++ b/CmdletsDescription/Users/Users.md @@ -0,0 +1,13 @@ +## Users + +1. List users in your tenant. + + ``` powershell + Get-MgUser -Top 10 -Property Id, DisplayName, BusinessPhones | Format-Table Id, DisplayName, BusinessPhones + ``` + +2. Filter a user in your tenant. + + ``` powershell + $user = Get-MgUser -Filter "displayName eq 'Megan Bowen'" + ``` \ No newline at end of file diff --git a/README.md b/README.md index 16a023dc2f3..4e154e24215 100644 --- a/README.md +++ b/README.md @@ -31,12 +31,6 @@ There is a set of samples in the `samples` folder to help in getting started wit ## Usage -* [Authentication](./README.md#authentication) - -* [Users](./README.md#users) - -* [Cloud Environment](./README.md#cloud-environment) - ## Authentication The SDK supports two types of authentication: delegated access and app-only access. - Delegated access. @@ -83,105 +77,17 @@ The SDK supports two types of authentication: delegated access and app-only acce $Cert = Get-ChildItem Cert:\LocalMachine\My\$CertThumbprint Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -Certificate $Cert ``` -## Users - -1. List users in your tenant. - - ``` powershell - Get-MgUser -Top 10 -Property Id, DisplayName, BusinessPhones | Format-Table Id, DisplayName, BusinessPhones - ``` - -2. Filter a user in your tenant. - - ``` powershell - $user = Get-MgUser -Filter "displayName eq 'Megan Bowen'" - ``` - -3. Create a new app registration. - - ``` powershell - New-MgApplication -DisplayName "ScriptedGraphPSApp" ` - -SignInAudience "AzureADMyOrg" ` - -Web @{ RedirectUris = "https://localhost"} - ``` -4. Sign out of the current logged-in context i.e. app only or delegated access. +1. Sign out of the current logged-in context i.e. app only or delegated access. ``` powershell Disconnect-MgGraph ``` +* [Applications](./CmdletsDescription/Applications/Application.md) -## Cloud Environment - -The SDK supports managing of cloud environments through `Get-MgEnvironment`, `Set-MgEnvironment`, `Add-MgEnvironment`, and `remove-MgEnvironment` commands -- Add Environment. - - A `user-defined` environment type is added and the name passed as `-Environment` parameter on the `Connect-Mgraph` command for user to be able to switch to a cloud of choice. - - Delegated access - - ``` powershell - # Using interactive authentication. - $Env = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' - Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" -Environment $Env.Name - ``` - or - - ``` powershell - # Using device code flow. - $Env = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' - Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" -UseDeviceAuthentication -Environment $Env.Name - ``` - or - - ``` powershell - # Using your own access token. - $Env = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' - Connect-MgGraph -AccessToken $AccessToken -Environment $Env.Name - ``` - - App-only access via Client Credential with a certificate. - - ``` powershell - # Using -CertificateThumbprint. - $Env = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' - Connect-MgGraph -TenantId "YOUR_TENANT_ID" -CertificateThumbprint "YOUR_CERT_THUMBPRINT" -ClientId "YOUR_APP_ID" -Environment $Env.Name - ``` - or - - ``` powershell - # Using -CertificateName. - $Env = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' - Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -CertificateName "YOUR_CERT_SUBJECT" -Environment $Env.Name - ``` - or - - ``` powershell - # Using -Certificate - $Env = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' - $Cert = Get-ChildItem Cert:\LocalMachine\My\$CertThumbprint - Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -Certificate $Cert -Environment $Env.Name - ``` - - Get Environment. - - A collection of environments will be returned by using the `Get-MgEnvironment` command. - - ``` powershell - Get-MgEnvironment - ``` - - Set Microsoft Graph Environment. - - `Set-MgEnvironment` command switches to a `user-defined` environment type using the existing microsoft graph session - - ``` powershell - Set-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT - ``` - - Remove Environment. - - `Remove-MgEnvironment` command removes an environment initially set by a user, from the existing microsoft graph session. It eventually defaults to Global. - - ``` powershell - Remove-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' - ``` +* [Users](./CmdletsDescription/Users/Users.md) +* [Cloud Environment](./CmdletsDescription/CloudEnvironment/CloudEnvironment.md) ## API Version From cabb0e04a124395bea377a248fb33d142d8366d0 Mon Sep 17 00:00:00 2001 From: Timothy Wamalwa Date: Tue, 21 Jun 2022 16:14:08 +0300 Subject: [PATCH 10/16] Updated readme and added profile folder --- CmdletsDescription/Profile/Profile.md | 1 + README.md | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 CmdletsDescription/Profile/Profile.md diff --git a/CmdletsDescription/Profile/Profile.md b/CmdletsDescription/Profile/Profile.md new file mode 100644 index 00000000000..7cc9cdd0b60 --- /dev/null +++ b/CmdletsDescription/Profile/Profile.md @@ -0,0 +1 @@ +## Profile \ No newline at end of file diff --git a/README.md b/README.md index 4e154e24215..6418e0b9f36 100644 --- a/README.md +++ b/README.md @@ -83,10 +83,14 @@ The SDK supports two types of authentication: delegated access and app-only acce ``` powershell Disconnect-MgGraph ``` +## Documentation and Resources + * [Applications](./CmdletsDescription/Applications/Application.md) * [Users](./CmdletsDescription/Users/Users.md) +* [Profile](./CmdletsDescription/Profile/Profile.md) + * [Cloud Environment](./CmdletsDescription/CloudEnvironment/CloudEnvironment.md) From 505b237eb2d9e361a189859d12e3091a13fe54b2 Mon Sep 17 00:00:00 2001 From: Timothy Wamalwa Date: Tue, 21 Jun 2022 16:17:44 +0300 Subject: [PATCH 11/16] Updated heading --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6418e0b9f36..62323bc5560 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ The SDK supports two types of authentication: delegated access and app-only acce ``` powershell Disconnect-MgGraph ``` -## Documentation and Resources +## More usage * [Applications](./CmdletsDescription/Applications/Application.md) From a5b4961a0c155f041163af3aff12c827c00d87f8 Mon Sep 17 00:00:00 2001 From: Timothy Wamalwa Date: Mon, 27 Jun 2022 13:05:19 +0300 Subject: [PATCH 12/16] Switched off the refresh flag --- tools/UpdateOpenApi.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/UpdateOpenApi.ps1 b/tools/UpdateOpenApi.ps1 index 15603194a5a..3ba4c4dae9c 100644 --- a/tools/UpdateOpenApi.ps1 +++ b/tools/UpdateOpenApi.ps1 @@ -39,7 +39,7 @@ $ModuleMapping.Keys | ForEach-Object -Begin { $RequestCount = 0 } -End { Write-D $ForceRefresh = $false # Check whether ForceRefresh is required, Only required for the First Request. if ($RequestCount -eq 0) { - $ForceRefresh = $true + $ForceRefresh = $false } try { From b3a2f1e5a95319c08d853ca5e188566e9961d3aa Mon Sep 17 00:00:00 2001 From: Timothy Wamalwa Date: Mon, 27 Jun 2022 13:19:29 +0300 Subject: [PATCH 13/16] Rolled back to original readme file --- .../Applications/Application.md | 9 -- .../CloudEnvironment/CloudEnvironment.md | 70 --------------- CmdletsDescription/Profile/Profile.md | 1 - CmdletsDescription/Users/Users.md | 13 --- README.md | 89 +++++++++++-------- 5 files changed, 50 insertions(+), 132 deletions(-) delete mode 100644 CmdletsDescription/Applications/Application.md delete mode 100644 CmdletsDescription/CloudEnvironment/CloudEnvironment.md delete mode 100644 CmdletsDescription/Profile/Profile.md delete mode 100644 CmdletsDescription/Users/Users.md diff --git a/CmdletsDescription/Applications/Application.md b/CmdletsDescription/Applications/Application.md deleted file mode 100644 index dd7cbc0c6a8..00000000000 --- a/CmdletsDescription/Applications/Application.md +++ /dev/null @@ -1,9 +0,0 @@ -## Applications - -1. Create a new app registration. - - ``` powershell - New-MgApplication -DisplayName "ScriptedGraphPSApp" ` - -SignInAudience "AzureADMyOrg" ` - -Web @{ RedirectUris = "https://localhost"} - ``` \ No newline at end of file diff --git a/CmdletsDescription/CloudEnvironment/CloudEnvironment.md b/CmdletsDescription/CloudEnvironment/CloudEnvironment.md deleted file mode 100644 index 70f59a328f1..00000000000 --- a/CmdletsDescription/CloudEnvironment/CloudEnvironment.md +++ /dev/null @@ -1,70 +0,0 @@ -## Cloud Environment - -The SDK supports managing of cloud environments through `Get-MgEnvironment`, `Set-MgEnvironment`, `Add-MgEnvironment`, and `remove-MgEnvironment` commands -- Add Environment. - - A `user-defined` environment type is added and the name passed as `-Environment` parameter on the `Connect-Mgraph` command for user to be able to switch to a cloud of choice. - - Delegated access - - ``` powershell - # Using interactive authentication. - $Env = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' - Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" -Environment $Env.Name - ``` - or - - ``` powershell - # Using device code flow. - $Env = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' - Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" -UseDeviceAuthentication -Environment $Env.Name - ``` - or - - ``` powershell - # Using your own access token. - $Env = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' - Connect-MgGraph -AccessToken $AccessToken -Environment $Env.Name - ``` - - App-only access via Client Credential with a certificate. - - ``` powershell - # Using -CertificateThumbprint. - $Env = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' - Connect-MgGraph -TenantId "YOUR_TENANT_ID" -CertificateThumbprint "YOUR_CERT_THUMBPRINT" -ClientId "YOUR_APP_ID" -Environment $Env.Name - ``` - or - - ``` powershell - # Using -CertificateName. - $Env = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' - Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -CertificateName "YOUR_CERT_SUBJECT" -Environment $Env.Name - ``` - or - - ``` powershell - # Using -Certificate - $Env = Add-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT' - $Cert = Get-ChildItem Cert:\LocalMachine\My\$CertThumbprint - Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -Certificate $Cert -Environment $Env.Name - ``` - - Get Environment. - - A collection of environments will be returned by using the `Get-MgEnvironment` command. - - ``` powershell - Get-MgEnvironment - ``` - - Set Microsoft Graph Environment. - - `Set-MgEnvironment` command switches to a `user-defined` environment type using the existing microsoft graph session - - ``` powershell - Set-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' -AzureADEndpoint 'AZURE_ENDPOINT' -GraphEndpoint 'GRAPH_ENDPOINT - ``` - - Remove Environment. - - `Remove-MgEnvironment` command removes an environment initially set by a user, from the existing microsoft graph session. It eventually defaults to Global. - - ``` powershell - Remove-MgEnvironment -Name 'YOUR_ENVIRONMENT_NAME' - ``` \ No newline at end of file diff --git a/CmdletsDescription/Profile/Profile.md b/CmdletsDescription/Profile/Profile.md deleted file mode 100644 index 7cc9cdd0b60..00000000000 --- a/CmdletsDescription/Profile/Profile.md +++ /dev/null @@ -1 +0,0 @@ -## Profile \ No newline at end of file diff --git a/CmdletsDescription/Users/Users.md b/CmdletsDescription/Users/Users.md deleted file mode 100644 index 815fe1dfe38..00000000000 --- a/CmdletsDescription/Users/Users.md +++ /dev/null @@ -1,13 +0,0 @@ -## Users - -1. List users in your tenant. - - ``` powershell - Get-MgUser -Top 10 -Property Id, DisplayName, BusinessPhones | Format-Table Id, DisplayName, BusinessPhones - ``` - -2. Filter a user in your tenant. - - ``` powershell - $user = Get-MgUser -Filter "displayName eq 'Megan Bowen'" - ``` \ No newline at end of file diff --git a/README.md b/README.md index 62323bc5560..cf533f2d67d 100644 --- a/README.md +++ b/README.md @@ -31,68 +31,79 @@ There is a set of samples in the `samples` folder to help in getting started wit ## Usage -## Authentication -The SDK supports two types of authentication: delegated access and app-only access. -- Delegated access. +1. Authentication - ``` powershell - # Using interactive authentication. - Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" - ``` + The SDK supports two types of authentication: delegated access and app-only access. + - Delegated access. - or + ``` powershell + # Using interactive authentication. + Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" + ``` - ``` powershell - # Using device code flow. - Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" -UseDeviceAuthentication - ``` + or - or + ``` powershell + # Using device code flow. + Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All" -UseDeviceAuthentication + ``` - ``` powershell - # Using your own access token. - Connect-MgGraph -AccessToken $AccessToken - ``` + or + + ``` powershell + # Using your own access token. + Connect-MgGraph -AccessToken $AccessToken + ``` + + - App-only access via Client Credential with a certificate. + + The certificate will be loaded from `Cert:\CurrentUser\My\` store when `-CertificateThumbprint` or `-CertificateName` is specified. Ensure the certificate is present in the store before calling `Connect-MgGraph`. -- App-only access via Client Credential with a certificate. + ``` powershell + # Using -CertificateThumbprint + Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -CertificateThumbprint "YOUR_CERT_THUMBPRINT" + ``` - The certificate will be loaded from `Cert:\CurrentUser\My\` store when `-CertificateThumbprint` or `-CertificateName` is specified. Ensure the certificate is present in the store before calling `Connect-MgGraph`. + or + + ``` powershell + # Using -CertificateName + Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -CertificateName "YOUR_CERT_SUBJECT" + ``` + + or + + ``` powershell + # Using -Certificate + $Cert = Get-ChildItem Cert:\LocalMachine\My\$CertThumbprint + Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -Certificate $Cert + ``` + +2. List users in your tenant. ``` powershell - # Using -CertificateThumbprint - Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -CertificateThumbprint "YOUR_CERT_THUMBPRINT" + Get-MgUser -Top 10 -Property Id, DisplayName, BusinessPhones | Format-Table Id, DisplayName, BusinessPhones ``` - or +3. Filter a user in your tenant. ``` powershell - # Using -CertificateName - Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -CertificateName "YOUR_CERT_SUBJECT" + $user = Get-MgUser -Filter "displayName eq 'Megan Bowen'" ``` - or +4. Create a new app registration. ``` powershell - # Using -Certificate - $Cert = Get-ChildItem Cert:\LocalMachine\My\$CertThumbprint - Connect-MgGraph -ClientId "YOUR_APP_ID" -TenantId "YOUR_TENANT_ID" -Certificate $Cert + New-MgApplication -DisplayName "ScriptedGraphPSApp" ` + -SignInAudience "AzureADMyOrg" ` + -Web @{ RedirectUris = "https://localhost"} ``` -1. Sign out of the current logged-in context i.e. app only or delegated access. +5. Sign out of the current logged-in context i.e. app only or delegated access. ``` powershell Disconnect-MgGraph ``` -## More usage - -* [Applications](./CmdletsDescription/Applications/Application.md) - -* [Users](./CmdletsDescription/Users/Users.md) - -* [Profile](./CmdletsDescription/Profile/Profile.md) - -* [Cloud Environment](./CmdletsDescription/CloudEnvironment/CloudEnvironment.md) - ## API Version From ad6172a2e1a3906a2f509400b5ea2e9f257335a8 Mon Sep 17 00:00:00 2001 From: Timothy Wamalwa Date: Tue, 28 Jun 2022 07:40:28 +0300 Subject: [PATCH 14/16] ForceRefresh for v1 only --- tools/UpdateOpenApi.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/UpdateOpenApi.ps1 b/tools/UpdateOpenApi.ps1 index 3ba4c4dae9c..2076ebb4b53 100644 --- a/tools/UpdateOpenApi.ps1 +++ b/tools/UpdateOpenApi.ps1 @@ -38,8 +38,8 @@ $ModuleMapping.Keys | ForEach-Object -Begin { $RequestCount = 0 } -End { Write-D $ModuleName = $_ $ForceRefresh = $false # Check whether ForceRefresh is required, Only required for the First Request. - if ($RequestCount -eq 0) { - $ForceRefresh = $false + if ($RequestCount -eq 0 -and $GraphVersion -eq "v1.0") { + $ForceRefresh = $true } try { From 64e0928355501ad5701e508b278afcf49b877dfa Mon Sep 17 00:00:00 2001 From: Timothy Wamalwa Date: Tue, 28 Jun 2022 16:38:09 +0300 Subject: [PATCH 15/16] Pointed to openapi test environment --- tools/DownloadOpenApiDoc.ps1 | 2 +- tools/UpdateOpenApi.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/DownloadOpenApiDoc.ps1 b/tools/DownloadOpenApiDoc.ps1 index 4b630c2b8b2..2ec6de56b8a 100644 --- a/tools/DownloadOpenApiDoc.ps1 +++ b/tools/DownloadOpenApiDoc.ps1 @@ -12,7 +12,7 @@ if (-not (Test-Path $OpenApiDocOutput)) { New-Item -Path $OpenApiDocOutput -Type Directory } -$OpenApiBaseUrl = "https://graphexplorerapi.azurewebsites.net" +$OpenApiBaseUrl = "http://devxapitest.azurewebsites.net" $OpenApiServiceUrl = ("$OpenApiBaseUrl/`$openapi?tags={0}&title=$ModuleName&openapiversion=3&style=Powershell&graphVersion=$GraphVersion" -f $ModuleRegex) if ($ForceRefresh.IsPresent) { $OpenApiServiceUrl = "$OpenApiServiceUrl&forceRefresh=true" diff --git a/tools/UpdateOpenApi.ps1 b/tools/UpdateOpenApi.ps1 index 2076ebb4b53..15603194a5a 100644 --- a/tools/UpdateOpenApi.ps1 +++ b/tools/UpdateOpenApi.ps1 @@ -38,7 +38,7 @@ $ModuleMapping.Keys | ForEach-Object -Begin { $RequestCount = 0 } -End { Write-D $ModuleName = $_ $ForceRefresh = $false # Check whether ForceRefresh is required, Only required for the First Request. - if ($RequestCount -eq 0 -and $GraphVersion -eq "v1.0") { + if ($RequestCount -eq 0) { $ForceRefresh = $true } From 5a925f340977e9414085c72bf382529f4e432d20 Mon Sep 17 00:00:00 2001 From: Timothy Wamalwa Date: Tue, 28 Jun 2022 19:51:52 +0300 Subject: [PATCH 16/16] Disabling condition check for successful docs download and diff check --- .../generation-templates/generate-service-modules.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/generation-templates/generate-service-modules.yml b/.azure-pipelines/generation-templates/generate-service-modules.yml index a3b0c613742..6237f7ec593 100644 --- a/.azure-pipelines/generation-templates/generate-service-modules.yml +++ b/.azure-pipelines/generation-templates/generate-service-modules.yml @@ -33,7 +33,7 @@ jobs: - job: GenerateServiceModules displayName: Service module generation timeoutInMinutes: 840 - condition: and(succeeded(), ne(stageDependencies.DownloadOpenAPIDocs.GetLatestDocs.outputs['OpenAPIDocDiff.ModulesWithChanges'], '')) + #condition: and(succeeded(), ne(stageDependencies.DownloadOpenAPIDocs.GetLatestDocs.outputs['OpenAPIDocDiff.ModulesWithChanges'], '')) variables: Branch: ${{ parameters.Branch }} ModulesToGenerate: ${{ parameters.ModulesToGenerate }}