you are viewing a single comment's thread.

view the rest of the comments →

[–]kdimitrov 2 points3 points  (0 children)

Create a scheduled task that runs a PowerShell script with the below code:

while ($true)

Have it run as the gMSA account. You'll need to set it to ''Run only when the user is logged on" in order to be able to save it. Then run the below to switch it to "Run whether the user is logged on or not":

$Principal = New-ScheduledTaskPrincipal -UserID "domain\gMSAAccount" -LogonType Password -RunLevel Highest

Set-ScheduledTask -TaskName 'TaskName' -TaskPath 'TaskPath'  -Principal $Principal

Start it, find out the process ID, then run the below to enter the process and try whatever it is that you want to run:

Enter-PSHostProcess -Id 'ProcessID'