Quantcast
Channel: Azure Virtual Machines forum
Viewing all articles
Browse latest Browse all 12545

How To set Default WinRm CertificateThumbprint Azure VM

$
0
0

Hello i hava a problem

I created sosm VM on azure to invoke coammands i need to install cert on my local machine.

It worked! but now i had a wrong Cloud Service name. i Created a nieuw service and a vm but i atatched the VHD of an existing system it is running.

But now i want to invoke a command an got an error that i dont have a certificate.

Example of my code for inatlling a cert on local machine:

$winRMCert = (Get-AzureVM -ServiceName $ServiceName -Name $VMName | select -ExpandProperty vm).DefaultWinRMCertificateThumbprint
            $AzureX509cert = Get-AzureCertificate -ServiceName $ServiceName -Thumbprint $winRMCert -ThumbprintAlgorithm sha1
            $certTempFile = [IO.Path]::GetTempFileName()
            $AzureX509cert.Data | Out-File $certTempFile
            # Target The Cert That Needs To Be Imported
            $CertToImport = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 $certTempFile
            $store = New-Object System.Security.Cryptography.X509Certificates.X509Store "Root", "LocalMachine"
            $store.Certificates.Count
            $store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite)
            $store.Add($CertToImport)
            $store.Close()
            Remove-Item $certTempFile

BTW this code works

after tring to run this code i get an error that my:

$winRMCert

is $NULL

after som tries and research i found out that my DefaultWinRmCertificateThumbprint empty is

How can i restore that ?


Viewing all articles
Browse latest Browse all 12545

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>