Change default TimeZone via Powershell API for all User

  • 3
  • Question
  • Updated 3 weeks ago

Hey,


I want to Change the TimeZone for all ShareFile User. I found a Script via Powershell API. Now my Problem is, that I cannot get a list of supported TimeZones and the correct Syntax for all TimeZones.


Here is the script for better understanding:

# Import the ShareFile SnapIn
 
Add-PSSnapin sharefile -Verbose
 
# Call for Credentials of ShareFile Subdomain "XXX.sharefile.eu"
 
$sfclient = Get-SFclient -Name "\\ad\temp\sflogin.sfps"
 
# The import file would typically be an exported contact list from Outlook or equivalent
# The import file contains "E-mail Address" and "Name" seperated with a "," as delimiter.
 
$contacts = Import-Csv "\\ad\temp\input.csv"
 
foreach ($contact in $contacts)
{
        if ($contact.'E-mail Address')
       
    {
    $Employee = Send-SfRequest -Client $sfClient -Entity Accounts\Employees | where email -like $contact.'E-mail Address'
    $testuser = Send-SfRequest -Client $sfClient -Entity Users -Id $Employee.Id
 
# JSON to set UserPreferences as required *** in this excample TimeZone ***
 
$json = @{"TimeZone"="-300,US,M/d/yy,h:mmt"} | ConvertTo-Json
 
# Send Request with PATCH METHOD to update the Preferences of Entity "Users" depending on UserID with above defined Value
    send-SfRequest -Client $sfClient -Method PATCH -Entity Users -Id $testuser.Id -Navigation Preferences -BodyText $json
 
    # Just for Information the Name and IDs of all patched Accounts.
 
    Write-host "Employee ID" $Employee.Id
    Write-host "Testuser ID" $testuser.Id
    Write-host "Employee Email" $contact.'E-mail Address'
    Write-host "Contact Name" $contact.Name
   
    }
 
}


So I Need a List of supported Syntaxes for the json

$json = @{"TimeZone"="-300,US,M/d/yy,h:mmt"}


Thanks in advance and best regards

Julian


Photo of Julian Jakob

Julian Jakob

  • 2 Posts
  • 0 Reply Likes

Posted 5 months ago

  • 3
Photo of Julian Jakob

Julian Jakob

  • 2 Posts
  • 0 Reply Likes

Any Ideas?


Thanks for your help!

Photo of Colm Govin

Colm Govin

  • 1 Post
  • 0 Reply Likes
Hi Julian,

You are nearly there.

If you log into your ShareFile account in the web and go to the page where you can change your default timezone, for example:

https://subdomain.sharefile.com/settings/personal/editprofile<br>
Turn on developer tools, preserving the log and disabling the cache checked.

If you select save under where your Time and Date format is in ShareFile, you will start to see the requests made towards ShareFile in the Networking tab.

Select the preferences token and review the header (https://subdomain.sf-api.com/sf/v3/Users(f1a7e388-226f-4fd1-bdb7-6907b6f9ac2b)/Preferences)

Scrolling down as far as Request Payload will show you everything that is sent including the format that we expect. For example if I am in the UK, the format will be like this:

0,EU,dd/MM/yyyy,HH:mm

This is an explanation then of the above, comma separated.
UTC +00:00,EU Daylight Savings,Day/Month/Year,Hours:Minutes(24-hour Format)

For the desired format you can turn on developer tools as I did above and set the timezone format in the sharefile web application and save.