Used to work on server 2016 but doesnt work on server 2019. What could be the issue?
2020-02-01 22:12:22.521 -05:00 [INF] Post-Request Script output:
Error - CmdletInvocationException: Object reference not set to an instance of an object.
at System.Management.Automation.PowerShell.EndInvoke(IAsyncResult asyncResult)
at Certify.Management.PowerShellManager.<>c__DisplayClass0_1.b__5() in C:\Work\GIT\certify\src\Certify.Shared\Management\PowerShellManager.cs:line 86
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Certify.Management.PowerShellManager.d__0.MoveNext() in C:\Work\GIT\certify\src\Certify.Shared\Management\PowerShellManager.cs:line 95
Please keep in mind that when your script runs during certificate renewal, it does so as Local System, not as your user account, so if your script depends on your permissions (or environment variables) then you need to consider other approaches.
Some people prefer to write the required output (such as the latest certificate thumbprint value) to a text file then use that in another script (perhaps run manually during a maintenance window or as a scheduled task), that way you can also debug interactively while developing your script in Powershell ISE etc