ARM2009
asked on
Output from Powershell is truncating output - need to autosize width to see all the data
running script to reconsile licenses in O365 and the output is getting truncated.
script is below
Get-MsolUser -All | select displayname, licenses | Format-Table -autosize | Out-File c:\licensed-users.csv
since a user has multiple licenses, that field is getting truncated.
used the following but it also wraps up to a second line, hard to import in excel
Get-MsolUser -All | select displayname, licenses | FT Displayname, Licenses -Wrap | Out-File c:\licensed-users.csv
Is there a way to specify width of column so it does not truncate output?
script is below
Get-MsolUser -All | select displayname, licenses | Format-Table -autosize | Out-File c:\licensed-users.csv
since a user has multiple licenses, that field is getting truncated.
used the following but it also wraps up to a second line, hard to import in excel
Get-MsolUser -All | select displayname, licenses | FT Displayname, Licenses -Wrap | Out-File c:\licensed-users.csv
Is there a way to specify width of column so it does not truncate output?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
the second option works well.. lists them in one line without truncating.
ASKER
just rechecked the output.... its not truncating but not listing the license name properly... basically repeats the same name.
user that had 2 different license, listed as below
Microsoft.Online.Administr ation.User License, Microsoft.Online.Administr ation.User License
so no way to differentiate
user that had 2 different license, listed as below
Microsoft.Online.Administr
so no way to differentiate
Sorry, can't test the original command; try this:
Get-MsolUser -All | Select-Object DisplayName, @{Name="Licenses"; Expression={($_.Licenses | Out-String -Stream) -join ", "}} | Export-Csv -Path c:\licensed-users.csv -NoTypeInformation
ASKER
result is as follows
"USER-Display NAME",", ExtensionData AccountSku AccountSkuId ServiceStatus , ------------- ---------- ------------ ------------- , System.Runtime.Serializati ... Microsoft.Online.Administr ... TENANT:RIGHTSMANAGEMENT {Microsoft.Online.Administ ..., System.Runtime.Serializati ... Microsoft.Online.Administr ... TENANT:ENTERPRISEWITHSCAL {Microsoft.Online.Administ ..., System.Runtime.Serializati ... Microsoft.Online.Administr ... TENANT:PROJECTONLINE_PLAN_ 2 {Microsoft.Online.Administ ..., , "
all in one line.... as you can see this user has 3 licenses, seems like the license are listed in full, the truncated part can be deleted at import.
easier way to do this without post cleanup?
"USER-Display NAME",", ExtensionData AccountSku AccountSkuId ServiceStatus , ------------- ---------- ------------ ------------- , System.Runtime.Serializati
all in one line.... as you can see this user has 3 licenses, seems like the license are listed in full, the truncated part can be deleted at import.
easier way to do this without post cleanup?
Seems like you're looking for the AccountSkuId?
Get-MsolUser -All | Select-Object DisplayName, @{Name="Licenses"; Expression={($_.Licenses | Select-Object -ExpandProperty AccountSkuId) -join ", "}} | Export-Csv -Path c:\licensed-users.csv -NoTypeInformation
ASKER
Thanks! that worked,
ASKER
this does not give the right information for licenses
shows license as "System.Collections.Generi
instead of
{Tenant:ENTERPRISEWITHSCAL
with -Wrap the result is as follows ... goes to 2 lines.
{Tenant:RIGHTSMANAGEMENT, Tenant:ENTERPRISEWITHSCAL,
nant:PROJECTONLINE_PLAN_2}