-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSharefile_List_Disabled_Users.ps1
More file actions
58 lines (45 loc) · 1.71 KB
/
Copy pathSharefile_List_Disabled_Users.ps1
File metadata and controls
58 lines (45 loc) · 1.71 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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"
}
Function FindDisabledUsers {
Param ( [string]$UserType = "employee")
$client = Get-SfClient -Name "c:\temp\sflogin.sfps"
$entity = "";
switch ($UserType.ToLower()) {
"employee" {
$entity = 'Accounts/Employees';
}
"client" {
$entity = 'Accounts/Clients';
}
}
$sfUsers = Send-SfRequest -Client $client -Entity $entity
$fileOutput = @()
$user_count = 0
$disableduser = 0
foreach ($sfUserId in $sfUsers) {
$sfUser = Send-SfRequest -Client $client -Entity Users -Id $sfUserId.Id -Expand Security
$user_count = $user_count + 1
switch ($sfUser.Security.IsDisabled ) {
"True" {
$fileOutput += New-Object PSObject -Property @{'UserId' = $sfUserId.Id; 'FullName' = $sfUser.FullName; 'Email' = $sfUser.Email}
write-host $sfUser.Email
$disableduser = $disableduser + 1
}
}
}
$fileOutput | Export-Csv ("C:\temp\" + $UserType + ".csv") -Force -NoTypeInformation
Write-Host $UserType + "$Total user number: " + $user_count
Write-Host $UserType + "Disabled user number: " + $disableduser
}
write-host "Checking employee"
write-host ""
write-host ""
FindDisabledUsers -UserType "employee";
write-host "Checking clients"
FindDisabledUsers -UserType "client";