I'm new to PowerShell I want to send 3 different responses to 3 different user prompts that I get when running a PowerShell script using another PowerShell script in Jenkins
I tried
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[System.Windows.Forms.SendKeys]::SendWait("y")
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")
[System.Windows.Forms.SendKeys]::SendWait("y")
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")
[System.Windows.Forms.SendKeys]::SendWait("dummytext")
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")
$command = "D:\testing\source\sample.ps1" + " -param1 'dummyParam'"
Invoke-Expression $command
but I keep getting this error
Exception calling "SendWait" with "1" argument(s): "Access is denied"
At D:\testing\powershell\testing.ps1:6 char:1
+ [System.Windows.Forms.SendKeys]::SendWait("y")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : Win32Exception
Build step 'PowerShell' marked build as failure
Finished: FAILURE
Does anyone how to fix this issue