Sharefile Powershell SDK not working as expected

  • 1
  • Question
  • Updated 2 weeks ago
I'm trying to automate the sharefile user creation through powershell, though the script is executing without any issues, I'm not seeing any user account created in Sharefile. When I try to create user using Sharefile web portal, it gets created. Not sure if there is any sync happening between AD and Sharefile. Below is the script used, can anyone suggest on this and let me know if any corrections needed in script?

------------------------------------------------------------------
Add-PSSnapin ShareFile
$sfClient = New-SfClient

#The import file would typically be an exported contact list from Outlook or equivalent
$contacts = Import-Csv C:\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.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"}
    }
}
-----------------------------------------------------
Photo of Vijay Bhasker

Vijay Bhasker

  • 2 Posts
  • 0 Reply Likes

Posted 3 weeks ago

  • 1
Photo of Luke Skrzypek

Luke Skrzypek, Employee

  • 48 Posts
  • 5 Reply Likes
Hi, 

Have you tried using $sfClient.Client.Users.Create(...).Execute() instead?
It should be more straightforward than assembling the request yourself.
(Edited)
Photo of Vijay Bhasker

Vijay Bhasker

  • 2 Posts
  • 0 Reply Likes
Hi Luke,

Tried, it didn't work either
Photo of Luke Skrzypek

Luke Skrzypek, Employee

  • 48 Posts
  • 5 Reply Likes
What are you getting as a response back from the Users.Create().Execute call?