Quantcast
Channel: /r/powershell – How to Code .NET
Viewing all articles
Browse latest Browse all 8793

Get informations of only E3 licenced users in Office365

$
0
0

Hi Guys,

I have been using script for Office365 Licence Tracking but its returning both office365 licence and unlicenced users. I want to fetch licenced users. Thanks in advance

$OutputFile = "C:ExportO365LicensedADEnabledUsers.csv" $T1 = @() $O365Users = Get-MsolUser -All ForEach ($O365User in $O365Users) { $ADuser = Get-ADUser -Filter { UserPrincipalName -eq $O365User.UserPrincipalName } -Properties whenCreated, Department, Company, Enabled If (($ADUser.Enabled -eq $true) -and ($O365User.isLicensed = $true)) { $T1 += New-Object psobject -Property @{ CollectDate = $(Get-Date); ADUserUPN = $($ADUser.UserPrincipalName); O365UserUPN = $($O365User.UserPrincipalName); ADUserCreated = $($ADUser.whenCreated); ADUserDepartment = $($ADUser.Department); ADUserCompany = $($ADUser.Company); ADUserEnabled = $($ADUser.Enabled); O365Licensed = $($O365User.isLicensed) } } } $T1 = $T1 | Sort-Object -Property ADUserCreated $T1 | Format-Table $T1 | Export-Csv -Path $OutputFile -NoTypeInformation Write-Host "Output to $OutputFile" 

submitted by /u/maxcoder88
[link] [comments]

The post Get informations of only E3 licenced users in Office365 appeared first on How to Code .NET.


Viewing all articles
Browse latest Browse all 8793

Trending Articles