How to remove remotely Outlook profile? Cannot find path 'HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles' because it does not exist.

Stanislav Dmytrenko 1 Reputation point


I am trying to remove remotely Outlook profile. I am local admin in my company.

When I use Invoke-Command:

Invoke-Command -ComputerName $currentPC -ScriptBlock {remove-item -Path "HKCU:\Software\Microsoft\Office\16.0\Outlook\Profiles"}

I'm getting the following error:

Cannot find path 'HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles' because it does not exist.

  • CategoryInfo : ObjectNotFound: (HKEY_CURRENT_US...utlook\Profiles:String) [Get-ChildItem], ItemNotFoundException
  • FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

I run the script with admin rights, so I have a feeling that scriptblock cannot identify HKEY_USERS for current user who is logged on remote machine
and somehow points to my registry entries. How can I make this script work?
Should I use user's SID on HKEY_USERS? Tanks

Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,707 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,453 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Rich Matheisen 45,756 Reputation points

    Should I use user's SID on HKEY_USERS?


    0 comments No comments

  2. Ian Xue (Shanghai Wicresoft Co., Ltd.) 34,111 Reputation points Microsoft Vendor


    HKCU is a symbolic link to a key representing the active user under HKEY_USERS key and the information in this key is built during the logon process. You can specify a user account with the -credential parameter.

    Best Regards,
    Ian Xue


    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  3. Limitless Technology 44,101 Reputation points


    Thank you for your question and reaching out. I can understand you are having issues related to Outlook profile.

    From Outlook 2013 (which supports side-by-side installations), the profiles are stored in HKEY_CURRENT_USER\Software\Microsoft\Office\%version%\Outlook\Profiles, where %version% is 15.0 for Outlook 2013, 16.0 for Outlook 2016, etc. In your Script try to change to this path with user context may be with logon script.

    --If the reply is helpful, please Upvote and Accept as answer--

    0 comments No comments