Disable users via Powershell

  • 1
  • Question
  • Updated 6 months ago
  • (Edited)
Hello...

Can you help me with the script to disable users?

I got the users with this variable:

$sfClients
= Send-SfRequest -Client $company -Entity Accounts\Clients |
Where-Object {$_.LastName -like 'Obama'} | Out-GridView


# disable the Contacts: (does not do anything)


foreach ($sfClient in $sfClients)
{
   
    {
       
        #create contact in ShareFile
        $NewSfClient = New-Object ShareFile.Api.Models.User
    
        #required fields
        $NewSfClient.FirstName = $sfClient.'FirstName'
        $NewSfClient.LastName = $sfClient.'LastName'
        $NewSfClient.Email = $sfClient.'Email'

        #optional fields
        $NewSfClient.Company = $sfClient.Company

        #Set user to disabled
      
                  
        Send-SfRequest $smartEU -Method PATCH -Body -$NewSfClient -Parameters @{"IsDisabled" = "true"}
                      
              
    }
}
Photo of David Birrer

David Birrer

  • 11 Posts
  • 0 Reply Likes

Posted 6 months ago

  • 1

Be the first to post a reply!