Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cert:/ drive not found after update to Powershell Core 7.4.x #9313

Closed
2 of 13 tasks
msft-erzhan opened this issue Feb 7, 2024 · 1 comment
Closed
2 of 13 tasks

Cert:/ drive not found after update to Powershell Core 7.4.x #9313

msft-erzhan opened this issue Feb 7, 2024 · 1 comment

Comments

@msft-erzhan
Copy link

Description

The powershell command Get-ChildItem Cert:\LocalMachine\My fails with the following error:

Get-ChildItem : Cannot find drive. A drive with the name 'Cert' does not exist.

I have this command in a setup script our team runs, where we create a self signed certificate. After adding a step to downgrade to powershell 7.2.x, the issue is no longer present.

Platforms affected

  • Azure DevOps
  • GitHub Actions - Standard Runners
  • GitHub Actions - Larger Runners

Runner images affected

  • Ubuntu 20.04
  • Ubuntu 22.04
  • macOS 11
  • macOS 12
  • macOS 13
  • macOS 13 Arm64
  • macOS 14
  • macOS 14 Arm64
  • Windows Server 2019
  • Windows Server 2022

Image version and build link

I am seeing the issue on image 20240128.1.0

I do not have a public example but I am internal to microsoft - reach out internally if the logs would be helpful.

Is it regression?

20240122.1.0

Expected behavior

I expect that when calling 'Get-ChildItem' within the 'Cert:/' drive to not throw an exception. Typically Cert:/ drive is created by default on Windows installation with the Microsoft.PowerShell.Security module.

Actual behavior

The powershell command Get-ChildItem Cert:\LocalMachine\My fails with the following error:

Get-ChildItem : Cannot find drive. A drive with the name 'Cert' does not exist.

This caused our setup script to fail, thus causing our test validations to fail. Needed to add the downgrade mitigation listed here to mitigate the issue: #9115

Repro steps

This was run within a AzureCLI@2 task, not a powershell task. Our task is defined like this:

      - task: AzureCLI@2
        displayName: "Run tests for ${{parameters.envName}}"
        inputs:
          scriptType: "pscore"
          azureSubscription: [sub_name]
          workingDirectory: "src/e2e"
          scriptLocation: "inlineScript"
          inlineScript: "npm run test-ci"

where the npm command will invoke a setup powershell script. Within this powershell script we use the powershell command Get-ChildItem Cert:\LocalMachine\My to check for existing certificates. This script fails due to the exception, failing the task.

@MaksimZhukov
Copy link
Contributor

Hello @msft-erzhan!
The issue was caused by updating the PowerShell version. Please find details in the related announcement.
To mitigate the issue, please downgrade PowerShell version in runtime:

      - name: Downgrade PowerShell
        shell: cmd
        run: |
          set "extractPath=C:\Program Files\PowerShell\7"
          curl -sLO https://github.com/PowerShell/PowerShell/releases/download/v7.2.17/PowerShell-7.2.17-win-x64.zip
          RMDIR "%extractPath%" /S /Q
          7z x PowerShell-7.2.17-win-x64.zip -o"%extractPath%"
          pwsh --version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants