Thursday, September 12, 2019

How to fetch Office 365 PowerBI License users using powershell



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Formatting using : http://hilite.me/
# Run this script in PowerShell ISE 64 bit
#Use Global Admin credential while prompts.


Import-Module MSOnline

$AzureAdCred = Get-Credential
Connect-MsolService -Credential $AzureAdCred

Connect-AzureAD -Credential $AzureAdCred


$Datetime= Get-Date -Format dd_MM_yyyy_HH.mm.ss
 $LogFileName=([string]::Concat("C:\Temp\Output_O365-E3License-Users_With_PowerBI-Activated " , $Datetime ,".csv"))
 New-Item  $LogFileName  -ItemType file

Add-Content $LogFileName -Value ([string]::Concat("User email" +","+ "License Assigned date"))

$users = Get-MsolUser -all | Where isLicensed -EQ $true


Foreach ($user in $users)

{
    $intFlag = 0
    $assignedplans = (Get-AzureADuser -ObjectId $user.UserPrincipalName).assignedplans

    foreach ($assignedplan in $assignedplans)

    {

        #Write-Host "$($assignedplan.service) "-ForegroundColor White
        # For : Forms use "OfficeForms" and for SharePoint use "SharePoint".

        If (($assignedplan.service -eq "PowerBI"))

        {

            Write-Host $user.UserPrincipalName -ForegroundColor White
            Add-Content $LogFileName -Value ([string]::Concat($($user.UserPrincipalName) +","+ $($assignedplan.AssignedTimestamp) ))
           

        }

    }

    

}



Value Service Friendly Name
ProcessSimple Flow for Office365
PowerAppsService PowerApps for Office 365
TeamspaceAPI Microsoft Teams
ProjectWorkManagement Microsoft Planner
Sway Sway
YammerEnterprise Yammer
MicrosoftOffice Office 365 ProPlus
MicrosoftCommunicationsOnline Skype for Business Online
SharePoint SharePoint Online
exchange Exchange Online
Deskless Staff Hub
RMSOnline Azure Information Protection Plan
Azure Rights Management
MultiFactorService Azure Multi-Factor Authentication
AADPremiumService Azure Active Directory Premium
SCO Intune A Direct
Adallom Microsoft Cloud App Security
VolumeLicensing Microsoft Business Center



http://www.wrish.com/post/assign-ems-licenses-with-dynamic-groups/



No comments:

Post a Comment

HTML

Script:

JS