-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateUsers.ps1
More file actions
26 lines (22 loc) · 882 Bytes
/
CreateUsers.ps1
File metadata and controls
26 lines (22 loc) · 882 Bytes
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
Import-Module ShareFile
#Import-Module ShareFile-Core # For PowerShell 7+
$sfClient = New-SfClient
#The import file would typically be an exported contact list from Outlook or equivalent
$contacts = Import-Csv .\Contacts.CSV
foreach ($contact in $contacts)
{
#make sure we have an email, name, and company
if ($contact.'E-mail Address' -and $contact.'First Name' -and $contact.'Last Name')
{
#create contact in ShareFile
$user = New-Object ShareFile.Api.Client.Models.User
#required fields
$user.FirstName = $contact.'First Name'
$user.LastName = $contact.'Last Name'
$user.Email = $contact.'E-mail Address'
#optional fields
$user.Company = $contact.Company
#create client user
Send-SfRequest $sfClient -Method POST -Entity Users -Body $user -Parameters @{"addshared" = "true"}
}
}