Forum Discussion

davidsharvit40's avatar
davidsharvit40
Copper Contributor
Feb 06, 2024

Security recommendations software update

Hi All,

 

the Security recommendations are showing suggestions to update some software.

Some are global so I can distribute them to the entire company, but some are relevant for only 100 laptops\PC, I tried to export the list of computer names from the defender which only gives me "Assets Export", date and version, but when i want to bulk add them It asks for "Member object ID or user principal name [memberObjectIdOrUpn] Required."

I tried to convert it, but I had many struggles, couldn't find any best practice around the internet.

Any suggestions?  

3 Replies

    • davidsharvit40's avatar
      davidsharvit40
      Copper Contributor

      TimBosch 

      Hi Tim!

      Someone got back to me on another forum with a great option that solved my problem- 

       

      Install-Module -Name AzureAD -AllowClobber -Scope CurrentUser


      Import-Module AzureAD


      Connect-AzureAD

       

      *Change device1 etc... names to the real devices

      # Specify the device names
      $deviceNames = @("Device1", "Device2", "Device3", "Device4")

      foreach ($deviceName in $deviceNames) {
      # Get device information
      $device = Get-AzureADDevice -Filter "displayName eq '$deviceName'"

      # Check if the device was found
      if ($device) {
      # Retrieve Member Object ID and UPN
      $memberObjectId = $device.ObjectId
      $userPrincipalName = $device.UserPrincipalName

      # Display the results
      Write-Host "Device: $deviceName"
      Write-Host "Member Object ID: $memberObjectId"
      Write-Host "User Principal Name (UPN): $userPrincipalName"
      Write-Host "---------------------------"
      } else {
      Write-Host "Device '$deviceName' not found."
      }
      }

      • TimBosch's avatar
        TimBosch
        Copper Contributor
        Great option!

        That was i was looking after but I wanted to check if it's possible to get the devices affected by the recommendation and then get it into a CSV file.

        Great that you found the solution.

Resources