microsoftgraph / microsoftgraph/msgraph-sdk-powershell
Get-MgReport* Cmdlets give PercentComplete error when overwriting a file
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 898
- Forks
- 230
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 31
Description
Describe the bug
When running any of the Get-MgReport* cmdlets, such as Get-MgReportEmailActivityUserDetail, you will receive the following PercentComplete error if the outfile already exists (hiding the progress and warnings to minimize noise):
>Get-MgReportEmailActivityUserDetail -period D180 -outfile emailactivity2.csv -ProgressAction SilentlyContinue -WarningAction SilentlyContinue
Get-MgReportEmailActivityUserDetail_Get1: Cannot set percent because PercentComplete cannot be greater than 100. (Parameter 'value')
Actual value was 2147483647.
Expected behavior
Get-MGReport* cmdlets should not run into the "Cannot set percent because PercentComplete cannot be greater than 100. (Parameter 'value')" error when completing successfully and overwriting an outfile.
How to reproduce
Write-Host "Make sure the output file doesn't already exist..."
Remove-Item C:\Example\emailactivity.csv -ErrorAction SilentlyContinue
Write-Host "Run the report to create the output file..."
Get-MgReportEmailActivityUserDetail -period D180 -outfile C:\Example\emailactivity.csv -ProgressAction SilentlyContinue -WarningAction SilentlyContinue
Write-Host "Run the report to a second time where it has to overwrite the output file... it generates the error."
Get-MgReportEmailActivityUserDetail -period D180 -outfile C:\Example\emailactivity.csv -ProgressAction SilentlyContinue -WarningAction SilentlyContinue
Write-Host "Delete the output file so we can show the error goes away... Inconsistent results when we don't pause after the file deletion..."
Remove-Item C:\Example\emailactivity.csv
Start-Sleep 5
Write-Host "Run the report a third time to show the error goes away when it doesn't have to overwrite the output file..."
Get-MgReportEmailActivityUserDetail -period D180 -outfile C:\Example\emailactivity.csv -ProgressAction SilentlyContinue -WarningAction SilentlyContinue
SDK Version
No response
Latest version known to work for scenario above?
2.34.0
Known Workarounds
No response
Debug output
No test tenant and debug output is sensitive
```</details>
### Configuration
- OS: Windows 11 24H2
- Arch: x64
Name Value
---- -----
PSVersion 7.5.4
PSEdition Core
GitCommitId 7.5.4
OS Microsoft Windows 10.0.26100
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
### Other information
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the overwrite sequence with Get-MgReportEmailActivityUserDetail, using an existing outfile and the supplied PowerShell progress and warning options. Compare the first-run and overwrite paths for the Get-MgReport* cmdlets. Done means overwriting the file completes successfully without the PercentComplete error and produces the expected report output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100