@@ -4,14 +4,40 @@ function Get-IcingaUsers()
4
4
[array ]$Username
5
5
);
6
6
7
- if ($null -eq $Username ) {
8
- return Get-LocalUser ;
9
- } else {
10
- [array ]$UserInformation = @ ();
11
- foreach ($UniqueUser in $Username ) {
12
- $UserInformation += (Get-LocalUser - Name $UniqueUser );
7
+ $UserData = Get-LocalUser ;
8
+ [array ]$UserOutput = @ ();
9
+
10
+ foreach ($user in $UserData ) {
11
+ if ($Username.Count -ne 0 ) {
12
+ if (-Not ($Username -Contains $user.Name )) {
13
+ continue ;
14
+ }
15
+ }
16
+
17
+ $UserOutput += @ {
18
+ ' AccountExpires' = $user.AccountExpires ;
19
+ ' Description' = $user.Description ;
20
+ ' Enabled' = $user.Enabled ;
21
+ ' FullName' = $user.FullName ;
22
+ ' PasswordChangeableDate' = $user.PasswordChangeableDate ;
23
+ ' PasswordExpires' = $user.PasswordExpires ;
24
+ ' UserMayChangePassword' = $user.UserMayChangePassword ;
25
+ ' PasswordRequired' = $user.PasswordRequired ;
26
+ ' PasswordLastSet' = $user.PasswordLastSet ;
27
+ ' LastLogon' = $user.LastLogon ;
28
+ ' Name' = $user.Name ;
29
+ ' SID' = @ {
30
+ ' BinaryLength' = $user.SID.BinaryLength ;
31
+ ' AccountDomainSid' = @ {
32
+ ' BinaryLength' = $user.SID.AccountDomainSid.BinaryLength ;
33
+ ' Value' = $user.SID.AccountDomainSid.Value ;
34
+ };
35
+ ' Value' = $user.SID.Value ;
36
+ };
37
+ ' PrincipalSource' = $user.PrincipalSource ;
38
+ ' ObjectClass' = $user.ObjectClass ;
13
39
}
14
40
}
15
41
16
- return $UserInformation ;
42
+ return $UserOutput ;
17
43
}
0 commit comments