I am new to powershell. Writting code in azure cloud shell. I want to get pfx certificate information using Get-PfxCertificate command. But its not taking any path, whether its blob path or local path. Giving error : for Local Get-PfxCertificate: Cannot find drive. A drive with the name 'C' does not exist.
for blob path Get-PfxCertificate: Cannot find drive. A drive with the name 'https' does not exist. enter image description here
Appreciated for the help.
Expecting to resolve file path issue
Get-PfxCertificate: Cannot find drive. A drive with the name 'C' does not exist.
If you are trying to execute the Get-PfxCertificate
command from Azure CLI
but C Drive
is not available in the cloud
To resolve the issue, kindly upload the same certificate
to Azure CLI and provide the cloud path as shown below
Ex: "/home/sagnic/thhejademotest-hello-20230716.pfx"
After uploading the certificate to Azure CLI
, use the ls
command to check the certificate
and the pwd
command to verify the path.
Get-PfxCertificate -FilePath "/home/sagnic/thhejademotest-hello-20230716.pfx"
Output:
If you have 100s of certificates to process, kindly move all certificates to one folder and try to execute the below powershell code.
#Define the folder path containing the certificate files
$folderPath = "C:\Venkat\Docker\Certificates"
#Get the list of certificate files in the folder
$certificateFiles = Get-ChildItem -Path $folderPath
#Loop through each certificate file
foreach ($certificateFile in $certificateFiles) {
# Get the PFX certificate
$pfxCertificate = Get-PfxCertificate -FilePath $certificateFile.FullName
$pfxCertificate
Write-Host "PFX Certificate Thumbprint: $($pfxCertificate.Thumbprint)"
}
Output: