Powershell - assign folders on delete, find storagezone id....

  • 1
  • Question
  • Updated 8 months ago
With quite a bit of research I've managed to script modifying user settings and generating a welcome message.  There are two things I can't figure out though.  One is how to reassign a user's files when deleting them from the system.  The latest conversation on this topic I could find was dated two years ago, and at that time this wasn't possible, but maybe it is now.  The other is how to set their StorageZone.  The problem I'm having with the StorageZone is that I have no idea what the ID is or how to find it.
Photo of Maurene Garza

Maurene Garza

  • 4 Posts
  • 4 Reply Likes

Posted 12 months ago

  • 1
Photo of Casimir Simpson

Casimir Simpson

  • 3 Posts
  • 1 Reply Like

Unfortunately, you are not able to reassign a user’s data because there are a lot of moving parts to completing that task. We are working on streamlining the process to promote a more user-friendly experience when a data reassignment fails. 

In regards to your second question, you will need to go to api.sharefile.com in order to pull the zone ID.  Afterwards, select API entities, then click zones and select get zone by ID. If you run the API from that page, then look for “ID” in the results. You will notice an ID beginning with the letter “Z”. That is your zone ID, and we mainly use it to verify whether you have a private server or a cloud base server.
(Edited)
Photo of Maurene Garza

Maurene Garza

  • 4 Posts
  • 4 Reply Likes
Thank you!  I found my zone ID, now I have to figure out how to script setting it for a user, if that will even be possible via Powershell.

Which I found by searching these forums:

$user = Send-SfRequest -Client $sfClient -Method GET -Entity Users -Parameters @{"emailaddress" = "chester.tester@blah.com"}

Send-SfRequest -Client $sfClient -Method PATCH -Entity Users -Id $user.ID -BodyText '{ "DefaultZone" :
{
"Id":"blahblahblah"
}
}'
(Edited)
Photo of Maurene Garza

Maurene Garza

  • 4 Posts
  • 4 Reply Likes
Also, I found a way to completely delete an account AND reassign the folders.  I verified it works.

$user = Send-SfRequest -Client $sfClient -Method GET -Entity Users -Parameters @{"emailaddress" = "chester.testera@blah.com"}

send-sfrequest -client $sfclient -method delete -uri $user.url.absoluteuri -parameters @{"completely" = "true"; "itemsreassignto" = "blahblahblah"}

Photo of JEBE

JEBE

  • 3 Posts
  • 1 Reply Like
Hi Maurene, what do you enter for blablabla in the parameter "itemsreassignto" = "blahblahblah" ?
is it the emailaddress or the user.id of the destination user ?
Where were you able to find the available parameters anyway ?
Photo of Jeremiah Strong

Jeremiah Strong

  • 23 Posts
  • 2 Reply Likes
Hello JEBE, 

The parameter for "blablabla" according to documentation appears to be the User ID of who you want to reassign the items to. 
http://api.sharefile.com/rest/docs/resource.aspx?name=Users 

Best,
Jeremiah
Photo of Jeremiah Strong

Jeremiah Strong

  • 23 Posts
  • 2 Reply Likes
Hi JEBE,

I thought this ShareFile User removal seemed like a nice option. If you are looking for a PowerShell Version, you can check this out: 
https://github.com/jstrong013/ShareFile/blob/master/Remove-SFUser.ps1

Disclaimer: I wrote this script later at night after a long day of work and relatively quickly... so be sure to review before executing. However, thought it would be helpful for whatever you are planning/implementing.