Guest User

Untitled

a guest
Jan 18th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. Param
  2. (
  3. [Parameter(Mandatory=$true)] [string] $jsonfile
  4. , [Parameter(Mandatory=$true)] [string] $breachname
  5. , [Parameter(Mandatory=$false)] [switch] $PassUsersToPipeline
  6. )
  7.  
  8.  
  9. $json = Get-Content -Path $jsonfile | Convertfrom-Json
  10.  
  11. foreach ($rec in $json.BreachSearchResults | ?{$_.Breaches.Title -eq $breachname} )
  12. {
  13. $mail = "{0}@{1}" -f $rec.alias,$rec.domainname
  14. $mailFilter = "smtp:{0}" -f $mail
  15.  
  16. $user = Get-ADUser -Filter {ProxyAddresses -eq $mailFilter} -Properties displayname
  17.  
  18. if($PassUsersToPipeline)
  19. {
  20. $user
  21. }
  22. else
  23. {
  24. [pscustomobject] @{
  25. mail = $mail
  26. displayName = $user.displayName
  27. status = $user.Enabled
  28. }
  29. }
  30. }
Add Comment
Please, Sign In to add comment