I wrote a script for disabling/enabling the new 25H2 Start Menu layout. I've verified that the standalone script (as in, the .ps1 file) works correctly when ran from an elevated powershell.
I then proceeded to integrate it into tweaks.json. Running Compile.ps1 -run works as expected, without raising any errors. However, when attempting to run the script from within WinUtil, the following cryptic exception is thrown:
[0;33mWARNING: A runtime exception occurred.
WARNING: The argument is null. Provide a valid value for the argument, and then try running the command again.
I pinpointed the warning being printed by Invoke-WinUtilScript.ps1 in line 31 by the following code:
} catch [System.Management.Automation.RuntimeException] {
Write-Warning "A runtime exception occurred."
Write-Warning $PSItem.Exception.message
} # ...
so I attempted to print a stack trace in the same catch block in a few different ways as to get some idea how it fails like so:
$_.Exception.Message
$_.Exception.StackTrace
$_.ErrorDetails
$_.ScriptStackTrace
$PSItem.Exception.StackTrace
but I got nothing.
The only thing I can suspect is that, because I am using some C# code via Add-Type, Invoke-Command might be freaking out about the @ characters? I genuinely got no clue about how to tackle this. Any pointers would be very helpful!