-2

I'm trying to run Pester tests on a Windows 7 machine. I followed the instructions from here, and I also installed PSGet and executed Install-Module Pester.

This works on both the Windows 7 machines I have. I can run the pester tests from an elevated PowerShell console.

I have a .cmd file which runs the Pester tests, but I'm unable to run it from an elevated command prompt. This works on one Windows 7 machine, but it doesn't work on another one.

I followed the same instructions to install Pester on both the machines. Please suggest what I might be missing.

On the machine that 'doesn't work': When I run the Pester script from PowerShell, the Invoke-Pester works and the script runs as expected. But, when I try to run the .cmd file which points to the pester scripts, I get an error saying Invoke-Pester is not recognized as a cmdlet, function; which means, as far as I understood, Pester is not working from the command prompt.

On the machine that 'works':

I am able to run the Pester script from both PowerShell and command prompt windows. The script runs as expected.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Priyanka P
  • 29
  • 3

1 Answers1

2

I found that the particular laptop I was working on, had some permission issues (corporate issues), and I couldn't get the Pester scripts working from the command prompt.

Anyway, I moved on to another Windows 7 laptop and installed Pester using the following instructions:

  • Download PsGet.psm1 from https://github.com/psget/psget/
  • Copy PsGet.psm1 to your modules folder (e.g. Modules\PsGet)
  • Start a new PowerShell session and import the Pester module using the commands below:

    Get-Module -ListAvailable -Name Pester

    Import-Module PsGet

    Install-Module PsGet

    Import-Module Pester.psm1

    Install-Module Pester

  • Check the execution policy set on the computer with: Get-ExecutionPolicy. The output should be Unrestricted. Otherwise, run: Set-ExecutionPolicy Unrestricted

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Priyanka P
  • 29
  • 3