Issues with scripts that take files as input and run as gMSA
This may be another one of those instances where it's just unsupported when running gMSA's but I'll note it here just in case it is a bug :)
My running environment is:
OS: Windows Server 2022 PowerShell Universal: Version 2026.2.5 PSU runs as a Windows Service as LocalSystem
Repro script:
#.universal\scripts.ps1 (Sanitized):
New-PSUScript -Name 'Test.ps1' -Description 'Test' -Path 'Test.ps1' -Environment 'PowerShell 7' -Credential 'MyGmsaAccount' -Role @('MyRole') -PortalOutputType 'Text' -Icon 'alert' -DisplayOutputOnExecute -ExecutionRole @('MyRole')
# Script contents
Param(
[ComponentModel.DisplayName("Upload File")]
[File]$File
)
'Filename is {0}' -f $File.FileName
Set-Content -Path 'C:\test.xlsx' -AsByteStream -Value $File.Content
When choosing to run the script by uploading a file, the following error is logged in the console (before any of my script logic is executed):
Could not find file 'C:\Windows\TEMP\psufile.128.bin'.
(Number is variable through executions)
Hello @tholabrk
Thank you for the detailed report and the sanitized reproduction example.
The `Could not find file 'C:\Windows\TEMP\psufile.<number>.bin'` error is useful because it appears before your script logic executes. I would like to isolate whether this is related specifically to the combination of file parameters and the gMSA execution context.
Could you please try these two control tests on PSU 2026.2.5?
1. Run the same script with the `[File]$File` parameter, but temporarily remove `-Credential 'MyGmsaAccount'`. Please let me know whether the file upload completes successfully under the default service context.
2. Run a minimal script using the same gMSA credential, but without a `[File]` parameter, and confirm that it executes successfully under the expected account.
These results should help determine whether the failure is in file handling generally or specifically when file uploads are combined with the gMSA Run As context.
Because this is a public forum, please sanitize all evidence before posting. Remove credentials, tokens, license keys, cookies, private keys, full connection strings, email addresses, usernames, customer data, tenant or account identifiers, internal domains, hostnames, IP addresses, and private URLs. Please do not upload unredacted HAR files, memory dumps, database backups, or complete configuration files to this public thread.
Best regards,
Ruben Tapia
Hi @rubentapia,
Just to basically confirm, it is the gMSA-credential causing havoc, just to be complete, I have modified the original test example to:
'Filename is {0}' -f "test"
Set-Content -Path ($Env:Temp + "\test.xslx") -Value "test"(I changed the script to not save directly to C: as that causes a failure (permissions) but is largely irrelevant, so I use temp)
This script runs with or without gMSA credential
The old script, slightly modified to save in %temp% instead fails with gMSA, but runs fine without gMSA, that script now looks like this:
Param(
[ComponentModel.DisplayName("Upload File")]
[File]$File
)
'Filename is {0}' -f $File.Filename
Set-Content -Path ($Env:Temp + "\test.xslx") -AsByteStream -Value $File.ContentHello @tholabrk
Thank you for completing those additional tests. The results are very helpful and further isolate the behavior to the combination of the [File] parameter and the gMSA execution context.
We will adjust our lab scenario to match the conditions you have confirmed and attempt to reproduce the same behavior on our side.
Once our reproduction is completed, we will combine the lab results with the evidence you have already provided and escalate the case to our Development team for further review.
I will keep you updated once we have completed the replication.
Best regards,
Ruben Tapia
Hi @tholabrk
We encountered some limitations while attempting to reproduce the exact gMSA scenario in our lab, so we were not able to complete an independent reproduction under equivalent conditions.
However, the control tests you provided clearly isolate the reported behavior to the combination of the [File] parameter and the gMSA Run As context. Based on that evidence, we will escalate the case directly to our Development team for further review.
I will keep the thread updated when we receive additional findings or guidance from Development.
Best regards,
Hello @tholabrk
Just a quick update on this case.
Based on the testing and evidence you provided, we have now escalated the issue to our Development team for further review.
The reported behavior remains isolated to the combination of the [File] parameter and the gMSA Run As context. We will update this thread once we receive additional findings or guidance from Development.
Thank you again for your detailed testing and patience while we investigate this further.
Best regards,
Great, let me know if/when there's something I can do.
For now, I did manually work around this issue by having my script call an API that runs in an environment that runs as the gMSA account, a bit round-about but it works :D