I want to create a test with Pester. I have to create some files and then read them with a filter.
The problem I get is when I use $PSScriptRoot. If I run the test in the Windows PowerShell ISE, it is working.
The same test in a PowerShell using
Invoke-Pester -Output Detailed .\MyTest.Tests.ps1
returns an error:
ParameterBindingValidationException: Cannot bind argument to parameter 'Path' because it is null.
The $path is defined $targetPath = $PSScriptRoot. I tried to use $psISE like in this post with the same result. Also I noticed that $psISE returns the path of Pester and not the local path (in the screenshot below C:\Program Files\WindowsPowerShell\Modules\Pester\5.4.1).
How can I fix the script to run it with Windows PowerShell ISE, PowerShell and also in an Azure pipeline?


