-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreateHipChatUsersFromCsvFile.ps1
39 lines (30 loc) · 1.03 KB
/
CreateHipChatUsersFromCsvFile.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Creates HipChat users from a csv file
# Mainly cobbled together from https://github.com/lholman/hipchat-ps/blob/master/Publish-HipChatRoomMessage.psm1 and http://technet.microsoft.com/en-us/library/hh849971.aspx
# Text file like this
#Email,Name,Mention_name,Title
#[email protected],Philip Hale,PhilipHale,Job Title
#[email protected],Joe Blogs,JoeBlogs,Job Title
# Required
$apitoken = ""
$csvPath = "C:\path to\ExampleCsvFile.csv"
$password = ""
function CreateUser($email, $name, $mentionName, $title)
{
$url = "https://api.hipchat.com/v1/users/create"
$body = @{
auth_token = $apitoken
email = $email
name = $name
mention_name = $mentionName
title = $title
password = $password
}
Invoke-RestMethod -Method Post -Uri $url -Body $body
Write-Host "Created user $name"
}
$fileData = Import-Csv $csvPath
Foreach ($row in $fileData)
{
CreateUser $row.Email $row.Name $row.Mention_name $row.Title
Start-Sleep -s 4 #https://www.hipchat.com/docs/api/rate_limiting
}