-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSharefile_Disable_Users.ps1
More file actions
38 lines (30 loc) · 1.12 KB
/
Sharefile_Disable_Users.ps1
File metadata and controls
38 lines (30 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Add-PSSnapIn ShareFile
$Wcl = new-object System.Net.WebClient
$Wcl.Headers.Add(“user-agent”, “PowerShell Script”)
$Wcl.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
$config = "C:\temp\sflogin.sfps"
if (![System.IO.File]::Exists($config)) {
New-sfclient -Name "C:\temp\sflogin.sfps"
}
$txt = Read-Host -Prompt 'Please enter txt file path'
$emails = @()
if (![System.IO.File]::Exists($txt)) {
write-host "txt files doesn't exist, now quit"
exit
}
else {
$Emails = get-content -path $txt
$sflogin = Get-SfClient -Name "c:\temp\sflogin.sfps"
$count = 0
foreach ($email in $Emails) {
$user = Send-SFRequest –Client $sfLogin –Method GET –Entity "Users?emailaddress=$email" -Expand Security
$id = $user.Id
Send-SfRequest -Client $sfLogin -Method PATCH -Entity "Users($id)" -BodyText '{"Security": {"IsDisabled" : "True"}}'
write-host "Disable Account of " $user.FullName
$count = $count + 1
}
write-host ""
write-host ""
write-host ""
write-host "disabled $count Accounts"
}