PowerShell Get Items by User ID

  • 1
  • Question
  • Updated 9 months ago
I'm looking for a way to get files associated to an user ID that I've derived from a specific StorageZone.  At this point I've been able to get the list of user ID's but I'm having challenges finding any examples of getting the associated items to user ID.

I've plagiarized some code and have this so far:

Add-PSSnapIn ShareFile

$sfClient = Get-SfClient –Name "H:\unitedlex.sharefile.sfps"

$sfEmployees = Send-SFRequest -Client $sfClient -entity Accounts/Employees -expand "User,User/DefaultZone,User/Security"

$fileOutputEmployee =@()

foreach($sfEmployee in $sfEmployees) {
  $fileOutputEmployee += New-Object PSObject -Property @{'UserId'=$sfEmployee.User.Id; 'FullName'=$sfEmployee.User.FullName; 'Email'=$sfEmployee.User.Email; 'DefaultZoneId'=$sfEmployee.User.DefaultZone.Id; 'DefaultZoneName'=$sfEmployee.User.DefaultZone.Name; 'LastLoggedOn'=$sfEmployee.User.Security.LastAnyLogin}
}

$ShareFileUSEastEmployees = $fileOutputEmployee | where DefaultZoneName -Like "ShareFile US East"

$EmployeeID = foreach($ShareFileUSEastEmployee in $ShareFileUSEastEmployees) {
    Send-SfRequest -Client $sfClient -Entity Users -Id $ShareFileUSEastEmployee.UserId | Select Id
    }

Now that I've got the list of user ID's associated to a specific zone; how do I then get the items associated to the ID?
Photo of Travis Martinez

Travis Martinez

  • 5 Posts
  • 0 Reply Likes

Posted 9 months ago

  • 1
Photo of Zack Eleveld

Zack Eleveld

  • 22 Posts
  • 4 Reply Likes
Just to be clear, are you looking for files in their ShareFile folder or files that they have access to in shared folders?
Photo of Travis Martinez

Travis Martinez

  • 5 Posts
  • 0 Reply Likes
I'm looking for files in their ShareFile folder.  We have users that have been created with a default zone for the Citrix managed StorageZone.  We would like to migrate these to on prem storage.  I figure the firs step is getting the users for the StorageZone then list the files the user has in that zone.