Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Issue with powershell script

(0) ShareShare
ReportReport
Posted on by

Hi,  I'm working my way through these powershell scripts...seems like each one errors out on me and I have to figure it out.  Anyway I'm running this script:

$CertificateScriptWithCommand = “.\CertificateReconfiguration.ps1 -certificateFile c:\Personalcertfile.pfx -password personal_certfile_password -updateCrm -certificateType S2STokenIssuer -serviceAccount contoso\administrator -storeFindType FindBySubjectDistinguishedName”

Invoke-Expression -command $CertificateScriptWithCommand

Obviously I put in my information for the login, certification location and pwd. My latest error is this:

Read Permission to Access Certificate Private Key is not granted. Please check if Service Account exists.

I've already made sure the account I'm using does have permissions on the certificate key but I still have the issue. Ideas?

*This post is locked for comments

  • John Hoven Profile Picture
    John Hoven 360 on at
    RE: Issue with powershell script

    If you're using the default Network Service, make sure you enter in the script as:

    'NT AUTHORITY\NETWORK SERVICE'

    That got me by this same error message.  It will add the certificate if you just type in something like "NetworkService", and it will have the permission on the private key, but their validation logic that it added successfully fails to recognize it.  Hope it saves someone else some frustration...

  • mikas Profile Picture
    mikas 5 on at
    RE: Issue with powershell script

    Have you find how to fix it? Same thing here.. after running "Invoke-Expression -command $CertificateScriptWithCommand"  i get  Attempted to perform an unauthorized operation  Read Permission to Access Certificate Private Key is not granted.

  • RE: Issue with powershell script

    Ok I have to back up...I thought that fixed the previous issue but it did not.  When I get to the "Invoke-Expression -command $CertificateScriptWithCommand" I am still getting "Certificate private key is not found".  I did try uninstalling and reinstalling the Azure AD PowerShell Module...did not work.

  • Suggested answer
    Adrian Begovich Profile Picture
    Adrian Begovich 1,019 Super User 2025 Season 1 on at
    RE: Issue with powershell script

    Hi Burt H,

    Try uninstalling and reinstalling the Azure AD PowerShell Module.

  • RE: Issue with powershell script

    OK I worked past that issue.  I read somewhere that copying the keys to another folder can fix the issue.  Fortunately that fixed both my broken RDP and my powershell script issue.  I renamed the Machine Keys folder and let Windows create a new one.  Now I'm on my newest error.  When running the "Import-Module MSOnlineExtended -Force" powershell script I get this error:

    The specified module 'MSOnlineExtended' was not loaded because no valid module file was found in any module directory.

  • RE: Issue with powershell script

    No one has ran into this?  No ideas?

  • RE: Issue with powershell script

    I've ran the repairstore command and deleted and reimported the certificate...still no dice.

  • RE: Issue with powershell script

    Ok I got past this error only to run into another.  I added read permissions to the folder the key is stored in: C:\programdata\microsoft\crypto\RSA and that fixed the error.  Now I am getting an error saying "Certificate private key is not found."  I exported the certificate again and checked the RSA folder to make sure a new key was generated for today and there was.  So what next?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,436 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans