Hi @Ankit Rao
You can use this sample PowerShell code to get users. Please replace the marked area with relevant values.
$clientID = "_ _ _ _ _ _ _"
$clientSecret ="_ _ _ _ _ _ _"
$tenantDomain ="_ _ _ _ _ _ _"
$loginURL = "https://login.microsoft.com"
$resource = "https://graph.microsoft.com"
$body = @{grant_type="client_credentials";resource=$resource;client_id=$ClientID;client_secret=$ClientSecret}
$token = Invoke-RestMethod -Method Post -Uri $loginURL/$tenantdomain/oauth2/token?api-version=1.0 -Body $body
$apiUri = 'https://graph.microsoft.com/v1.0/users/'
$body = "{}"
$users = (Invoke-RestMethod -Headers @{Authorization= "Bearer $($token.access_token)" } -Uri $apiUri -Method Get -ContentType 'application/json')
For more details please refer to this documentation.
Hope this helps.
If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.