I am building a .NET 6 application in C# using Visual Studio 2022. The application has a worker service that runs a console application. A Group Managed Service Account (gMSA) has been created for me and I can successfully install the service (using PowerShell) under the gMSA credentials on my local PC as well as a staging server. The gMSA passes Active Directory credentials from the service context to my application and works correctly. However, I do not have a way to debug my application using the gMSA account on my local PC.
Using a container or Azure is not an option and because this is a console application, an IIS-based solution is not possible either. I initially thought I would use runas
to log into Visual Studio 2022 as the gMSA, but learned that runas would not work with a gMSA and that the preferred method to log into an application as a gMSA would be to use PsExec (64-bit version).
I attempted to do this, but was only able to log in via a command prompt as "nt authority\system" using
C:\psexec\PSExec64.exe -s cmd.exe
When I would attempt to log into the gMSA using
C:\psexec\PSExec64.exe \\local_pc\c$ -i -u gMSA_username -p ~ cmd.exe
no error message was displayed, but also no Microsoft copyright message (which is what is displayed when the command is successful). This seems to suggest the command failed in a way that could not be reflected in an error message. (It is worth mentioning that I also tried using both commands to open up a PSExec pipe and then connect using a gMSA, but I could not get that process to work.)
Adding to this issue is that Visual Studio 2022 no longer offers the "Start external program" functionality under the Debug section of a project's properties. So even if I was able to run a command prompt under a gMSA, I do not know how I could use that knowledge to log into Visual Studio under the gMSA credentials.
I would like to know how to debug my console application running as a service in Visual Studio 2022 using a gMSA. I am willing to do this using PSExec or another method. Any assistance offered will be greatly appreciated.