Forum Discussion
mfranhind115
Jul 14, 2022Brass Contributor
Powershell: get data from MsOnline
Hi all, I would extract some "basic" data like "UserPrincipalName, DisplayName, licenses, islicensed, creation date, last activation date" and others "nested" like AlternateEmailAddresses. If po...
- Jul 15, 2022Nice, expanding on my ugly script 😛
mfranhind115
Jul 14, 2022Brass Contributor
I'm already connected manually, I only run the script from:
#Create table
not from the beginning
it isnt right?
#Create table
not from the beginning
it isnt right?
mfranhind115
Jul 14, 2022Brass Contributor
it works!!!!
great thanks!
any chances to get infos of a user on the same row?
now it gets me lot of rows for every user
- Jul 14, 2022
You could change
$Licenses = [PSCustomObject]@{
User = $User.UserPrincipalName
LicenseSKU = $SKUfriendlyname.Product_Display_Name
Serviceplan = $serviceplan.Service_Plans_Included_Friendly_Names
}
$UsersLicenses += $Licensesto
$Licenses = [PSCustomObject]@{
User = $User.UserPrincipalName
DisplayName = $User.DisplayName
LicenseSKU = $SKUfriendlyname.Product_Display_Name
Serviceplan = $serviceplan.Service_Plans_Included_Friendly_Names
}
$UsersLicenses += $LicensesI added DisplayName as example, you can add rows to it from these values
- mfranhind115Jul 14, 2022Brass Contributorthank you Harm!
but I meant if we can put the infos of the user in the same row, not splitted in several rows...
thanks- Jul 14, 2022
You can do that, this was just an example of license gathering. You can start with something like this?
$Users = @()foreach ($user in Get-MsolUser -All | Sort-Object UserPrincipalName) {$info = [PSCustomObject]@{User = $User.UserPrincipalNameDisplayName = $User.DisplayName}$Users += $info}$Users | Sort-Object User | Export-Csv -NoTypeInformation -Delimiter ';' -Encoding UTF8 -Path c:\temp\users.csv