Win32_TSLicenseReport not generating report when AD has Japanese usernames

Nithin Thankachan 0 Reputation points
2024-09-18T18:52:50.6866667+00:00
$fileName = (Invoke-WmiMethod Win32_TSLicenseReport -Name GenerateReportEx).FileName
$fileEntries = (Get-WmiObject Win32_TSLicenseReport | Where-Object FileName -eq $fileName).FetchReportEntries(0, 0).ReportEntries

These commands succeed when I have ONLY usernames in english alphabets. The moment I add a username in Japanese language, the $fileEntries comes out as empty. When I manually generate report and save it, I cannot see the entry of usernames saved in Japanese language. This definitely seems like an encoding issue. How to get past this?

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,620 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,521 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Rich Matheisen 46,721 Reputation points
    2024-09-19T02:26:37.4933333+00:00

    That looks like it might be a problem with WMI, not PowerShell. Have you tried using Invoke-CIMMethod (using the same class name)? It may not make any difference, but it's easy enough to try. The WMI and CIM may use different MOF files to acquire the and process the information.

    Or it may be a problem with the installed languages on the RDS server (where the report is created). But that's a Windows configuration issue, not a PowerShell problem.


  2. Rich Matheisen 46,721 Reputation points
    2024-09-21T02:14:44.2533333+00:00

    I haven't tried this (and I have no RDS server, either):

    Import-Module RemoteDesktopServices
    Set-Location -Path 'rds:'
    $report = Get-ChildItem -Path RDS:\LicenseServer\IssuedLicenses\PerUserLicenseReports'
    $reportEntries = $report | ForEach-Object {
        $_.FetchReportEntries(0, 0).ReportEntries
    }
    $reportEntries | Export-Csv -Path "C:\path\to\your\report.csv" -NoTypeInformation
    
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.