Skip to content

Commit fb116ca

Browse files
author
TaraMeyer
committed
testing
1 parent 8e36225 commit fb116ca

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

docs-conceptual/azureadps-2.0-preview/signing-in-service-principal.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ms.reviewer: rodejo
1717

1818
This example describes how you can use a Service Principal to connect to your directory from within PowerShell. You would use this approach if you wanted to run an unattended script, as from Windows Scheduled tasks.
1919

20-
To enable this, we need to perform several steps.
20+
To enable this, several steps must be performed.
2121

2222
## Sign in to Azure AD PowerShell with an admin account
2323

@@ -51,7 +51,7 @@ $keyValue = [System.Convert]::ToBase64String($cert.GetRawCertData())
5151

5252
Next step is to create a new application and assign the certificate we created as a key credential:
5353

54-
```powershell
54+
```powershell
5555
$application = New-AzureADApplication -DisplayName "test123" -IdentifierUris "https://rodejo2177668"
5656
New-AzureADApplicationKeyCredential -ObjectId $application.ObjectId -CustomKeyIdentifier "Test123" -Type AsymmetricX509Cert -Usage Verify -Value $keyValue
5757
```
@@ -60,29 +60,29 @@ New-AzureADApplicationKeyCredential -ObjectId $application.ObjectId -CustomKeyId
6060

6161
To use the application to sign in into your directory with PowerShell you'll need to create a new service principal for this application:
6262

63-
```powershell
64-
$sp=New-AzureADServicePrincipal -AppId $application.AppId
63+
```powershell
64+
$sp=New-AzureADServicePrincipal -AppId $application.AppId
6565
```
6666

6767
## Give the Service Principal Reader access to the current tenant (Get-AzureADDirectoryRole)
6868

6969
We now have the ability to set the exact access rights this service principal has in your directory. In this example, we'll assign the access rights of the Directory Readers role in Azure AD:
7070

71-
```powershell
72-
Add-AzureADDirectoryRoleMember -ObjectId (Get-AzureADDirectoryRole | where-object {$_.DisplayName -eq "Directory Readers"}).Objectid -RefObjectId $sp.ObjectId
71+
```powershell
72+
Add-AzureADDirectoryRoleMember -ObjectId (Get-AzureADDirectoryRole | where-object {$_.DisplayName -eq "Directory Readers"}).Objectid -RefObjectId $sp.ObjectId
7373
```
7474

75-
This concludes the setup portion of the example.
75+
This concludes the setup portion of the example.
7676

7777
## Signing in into your tenant
7878

79-
We can now sign in to the directory using the new service principal.
79+
We can now sign in to the directory using the new service principal.
8080
> Note: if you;re running all these commands in one script, as you probably would do when trying this out, please remember that Azure AD requires some time to sync all the information you just entered through all of its components. In that case, add a Sleep cmdlet call here, this will make the script processing pause for 5 seconds:
8181
82-
```powershell
83-
Sleep -s 5
84-
```
85-
82+
```powershell
83+
Sleep -s 5
84+
```
85+
8686
To sign in you will need to find the ObjectID of the tenant you want to sign in to:
8787

8888
```powershell

0 commit comments

Comments
 (0)