Skip to content

Commit 0709c1a

Browse files
committed
Update Blog “bulk-onboarding-of-users-in-hpe-greenlake-edge-to-cloud-platform”
1 parent 6c820ee commit 0709c1a

File tree

1 file changed

+19
-26
lines changed

1 file changed

+19
-26
lines changed

content/blog/bulk-onboarding-of-users-in-hpe-greenlake-edge-to-cloud-platform.md

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,28 @@ So, my Excel file contains the following 2 sheets:
3939

4040
![Workspaces tab in Excel](/img/bulkimport-blog-picture-2.png "Workspaces tab in Excel")
4141

42-
43-
44-
## High-level algorithm
45-
42+
## High-level algorithm
4643

4744
Let’s look at the steps necessary to invite users from my spreadsheets:
4845

4946
1. Read command parameters to get the Excel filename
5047
2. Open spreadsheet to retrieve data
5148
3. For each workspace in Workspaces sheet
52-
- Prompt for Client Secret that matches the Client Id
53-
- Retrieve a session token using those credentials
49+
50+
* Prompt for Client Secret that matches the Client Id
51+
* Retrieve a session token using those credentials
5452
4. For each user in Users sheet
55-
- Lookup Client Id using workspace name
56-
- Call POST /identity/v1/users for user using email
57-
- Increase counter of invited users
53+
54+
* Lookup Client Id using workspace name
55+
* Call POST /identity/v1/users for user using email
56+
* Increase counter of invited users
5857
5. Display list of users invited in each workspace
5958

6059
## Putting things together in PowerShell
6160

6261
I decided to use PowerShell to write this script because it provides easy native access to Excel spreadsheets.
6362

64-
### Step 1 – Reading the parameter from the command line.
63+
### Step 1 – Reading the parameter from the command line.
6564

6665
```powershell
6766
Param($XLFile)
@@ -73,7 +72,6 @@ if ($Null -eq $XLFile)
7372
$XLFile = read-host "Enter name of the Excel file"
7473
}
7574
}
76-
7775
```
7876

7977
### Step 2 – Importing data from the 2 sheets of my spreadsheet.
@@ -86,10 +84,9 @@ if ($XLFile)
8684
{
8785
$users_excel = import-excel -path $XLFile -dataonly -worksheetname Users
8886
$workspaces_excel = Import-Excel -path $XLFile -dataonly -worksheetname Workspaces
89-
9087
```
9188

92-
*Note that I initialized 2 hash tables, one called $tokens that will store the token for a given Client Id (i.e Workspace) and another called $invited for storing the number of invited users for a given Client Id.*
89+
Note that I initialized 2 hash tables, one called $tokens that will store the token for a given Client Id (i.e Workspace) and another called $invited for storing the number of invited users for a given Client Id.
9390

9491
### Step 3 – Iterating over the Workspaces sheet to collect client secrets, and retrieve access tokens.
9592

@@ -124,7 +121,6 @@ if ($XLFile)
124121
}
125122
}
126123
}
127-
128124
```
129125

130126
Note that, at the end of this loop, I have a hash table of tokens indexed by Client Id, which I will use to call the API in the next section
@@ -175,7 +171,6 @@ Note that, at the end of this loop, I have a hash table of tokens indexed by Cli
175171
sleep 15
176172
}
177173
}
178-
179174
```
180175

181176
Note that before the loop, I initialized to zero the count of invited users for a given workspace. Also note the sleep 15 (seconds) at the end of the loop to avoid issues with rate limiting constraints which might raise a status code 429.
@@ -233,14 +228,13 @@ foreach ($workspace in $workspaces_excel ) {
233228
$_users_list | select Username, Status | ft -AutoSize
234229
235230
}
236-
237231
```
238232

239233
## Try it!
240234

241235
Let’s run this script, making sure to reference the right Excel spreadsheet:
242236

243-
```powershell
237+
```markdown
244238
PS /Volumes/Dev/GreenLake/GLP-API-Tooling/Scripts> ./bulk_invite.ps1 -XLfile userlist.xlsx
245239
Enter HPE GreenLake Client Secret for Workspace HPEDEV -GLCP- Hackshack: ********************************
246240
Enter HPE GreenLake Client Secret for Workspace Super Awesome Company: ********************************
@@ -257,27 +251,26 @@ List of users in workspace: HPEDEV -GLCP- Hackshack
257251

258252
Username Status
259253
-------- ------
260-
<email> VERIFIED
254+
<email> VERIFIED
261255
262-
256+
263257
264-
258+
265259
266-
<email> VERIFIED
260+
<email> VERIFIED
267261

268262
1 user(s) invited to workspace Super Awesome Company
269263
List of users in workspace: Super Awesome Company
270264

271265
Username Status
272266
-------- ------
273-
<email> VERIFIED
267+
<email> VERIFIED
274268
275-
269+
276270
277-
271+
278272
279-
<email> VERIFIED
280-
273+
<email> VERIFIED
281274
```
282275

283276
As you can see, the script has invited 1 user in each workspace, the second email being already a member of the workspace (thus no action is necessary).

0 commit comments

Comments
 (0)