Powershell script filter by Ad group

This topic is resolved

Share
Viewing 2 reply threads
  • Author
    Posts
    • #277985
      Adrian Higueros
      Participant
      • Topics: 2
      • Replies: 0
      Member Points: 62
      Rank: Level 1

      I have the powershell script below. Can anyone help me be able to filter it so it only applies to a group in AD. lets say “all staff”

       

       

      $csv = “C:\Reports\MobileDevices.csv”
      $results = @()
      $mailboxUsers = get-mailbox -resultsize unlimited
      $mobileDevice = @()

      foreach($user in $mailboxUsers)
      {
      $UPN = $user.UserPrincipalName
      $displayName = $user.DisplayName

      $mobileDevices = Get-MobileDevice -Mailbox $UPN

      foreach($mobileDevice in $mobileDevices)
      {
      Write-Output “Getting info about a device for $displayName”
      $properties = @{
      Name = $user.name
      UPN = $UPN
      DisplayName = $displayName
      FriendlyName = $mobileDevice.FriendlyName
      ClientType = $mobileDevice.ClientType
      ClientVersion = $mobileDevice.ClientVersion
      DeviceId = $mobileDevice.DeviceId
      DeviceMobileOperator = $mobileDevice.DeviceMobileOperator
      DeviceModel = $mobileDevice.DeviceModel
      DeviceOS = $mobileDevice.DeviceOS
      DeviceTelephoneNumber = $mobileDevice.DeviceTelephoneNumber
      DeviceType = $mobileDevice.DeviceType
      FirstSyncTime = $mobileDevice.FirstSyncTime
      UserDisplayName = $mobileDevice.UserDisplayName
      }
      $results += New-Object psobject -Property $properties
      }
      }

      $results | Select-Object Name,UPN,FriendlyName,DisplayName,ClientType,ClientVersion,DeviceId,DeviceMobileOperator,DeviceModel,DeviceOS,DeviceTelephoneNumber,DeviceType,FirstSyncTime,UserDisplayName | Export-Csv -notypeinformation -Path $csv

      0
    • #278850
      Michael Pietroforte
      Keymaster
      • Topics: 170
      • Replies: 676
      Post count: 1968
      Member Points: 26,774
      Author of the year 2018
      Rank: Level 4

      According to this post you can filter by group with this command:

      0
      • #301435
        Clayton
        Participant
        • Topics: 0
        • Replies: 1
        Post count: 3
        Member Points: 149
        Rank: Level 2

        The “VoicemailEnabled” would be your AD group you would change to your specific group you are needing to search within.

        1+
        avatar
    • #304334
      Karim Buzdar
      Moderator
      • Topics: 32
      • Replies: 117
      Post count: 374
      Member Points: 8,068
      Rank: Level 3

      Hi Adrian,

      Is your issue resolved?

      Thank you,

      0
Viewing 2 reply threads
  • You must be logged in to reply to this topic.
© 4sysops 2006 - 2020

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account