Compare AzureADUsers using github restapi

Welcome Forums General PowerShell Q&A Compare AzureADUsers using github restapi

Viewing 2 reply threads
  • Author
    Posts
    • #281689
      Participant
      Topics: 2
      Replies: 2
      Points: 11
      Rank: Member

      I have user email address stored in UserPrincipalName object

      $AzureADUsers | Select-Object -Property UserPrincipalName

      and trying to search that email and list email which doesn’t match using github rest API

      $Result = Invoke-RestMethod -Headers $Headers -Uri https://api.github.com/user/emails -Method Get
      $Result | Select-Object -Property email
      ForEach($email in $Result) {
      Invoke-RestMethod -Headers $Headers -Uri https://api.github.com/user/$UserPrincipalName -Method Get
      }

    • #281782
      Senior Moderator
      Topics: 9
      Replies: 1447
      Points: 5,419
      Helping Hand
      Rank: Community MVP

      Okay, Are you facing any issues with the above code ?

    • #281831
      Participant
      Topics: 2
      Replies: 2
      Points: 11
      Rank: Member

      Sorry my post got altered, I get this error. Wondering if object can be passed along withb rest Uri

      Invoke-RestMethod : {“message”:”Not Found”,”documentation_url”:”https://docs.github.com/rest”}
      At line:11 char:9
      + Invoke-RestMethod -Headers $Headers -Uri https://api.github.c
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
      + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
      Invoke-RestMethod : {“message”:”Not Found”,”documentation_url”:”https://docs.github.com/rest”}
      At line:11 char:9
      + Invoke-RestMethod -Headers $Headers -Uri https://api.github.c
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
      + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Viewing 2 reply threads
  • You must be logged in to reply to this topic.