Monday, September 2, 2019

How to find the users in Office 365 E3 License with "Forms" activated


 1

60
61
# Formatting using : http://hilite.me/
# Run this script in PowerShell ISE 64 bit
#Use Global Admin credential while prompts.

Set-ExecutionPolicy unrestricted
Install-Module MSOnline
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_Without_SharePoint-Activated " , $Datetime ,".csv"))
 New-Item  $LogFileName  -ItemType file

Add-Content $LogFileName -Value ([string]::Concat("User Name" +","+ "User Prinicpal Name" +","+ "Usage Location"))

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

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 "SharePoint")) { $intFlag = 1 } } If($intFlag -eq 0) { Write-Host "$($user.UserPrincipalName) "-ForegroundColor Green Add-Content $LogFileName -Value ([string]::Concat($($user.DisplayName) +","+ $($user.UserPrincipalName) +","+ $($user.UsageLocation))) $intFlag = 0 } }

No comments:

Post a Comment

HTML

Script:

JS