title: Login to power bi service online (silently i.e. without the popup) using powershell
body: <p>I would like to login to Power BI Online service and remove rows from a dataset using the REST API. I have the rest of the code going fine but the login seems to not work. This is what I tried. Can someone help me please? Thank you!</p>
  
  <pre><code>$pbiUsername = "abc.xyz@xxx.com"
  $pbiPassword = "Password"
  $clientId = "a81b2cc1-4c97-2323-bal4-eeb21c4c6e46"
  
  $body = @{"resource" = "https://analysis.windows.net/powerbi/api"
      "client_id" = $clientId;
      "grant_type" = "password";
      "username" = $pbiUsername;
      "password" = $pbiPassword;
      "scope" = "openid"
  }
  
  $authUrl = "https://login.windows.net/common/oauth2/token/"
  $authResponse = Invoke-RestMethod -Uri $authUrl –Method POST -Body $body
  
  $headers = @{
      "Content-Type" = "application/json";
      "Authorization" = $authResponse.token_type + " " + 
                        $authResponse.access_token
  }
  
  $restURL = "https://api.powerbi.com/v1.0/myorg/groups"
  $restResponse = Invoke-RestMethod -Uri $restURL –Method GET -Headers $headers
  </code></pre>