Import-StartLayout: Access to the path is denied RRS feed

  • Question

  • I am getting an access denied whenever I run a PowerShell script as administrator and need help finding a solution.  I am running it on Windows 10 Enterprise 1809.

    Here is the script and error message:

    $ScriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
    Import-StartLayout -LayoutPath $ScriptPath\LayoutModification.xml -MountPath $env:SystemDrive\
    PS D:\!Standard Desktop Installers\Start Menu Shortcuts> D:\!Standard Desktop Installers\Start Menu Shortcuts\Install_Start_Layout.ps1
    Import-StartLayout : Access to the path 'C:\Users\Default\AppData\Local\Microsoft\Windows\Shell\LayoutModification.xml' is denied.
    At D:\!Standard Desktop Installers\Start Menu Shortcuts\Install_Start_Layout.ps1:5 char:1
    + Import-StartLayout -LayoutPath $ScriptPath\LayoutModification.xml -Mo ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Import-StartLayout], UnauthorizedAccessException
        + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.Windows.StartLayout.Commands.ImportStartLayoutCommand

    The XML file that is reference is in the same directory as the PS1 file.  That is why I define the $ScriptPath variable.

    Friday, July 19, 2019 6:19 PM

All replies

  • Hi,

    Can you run the same script on another Windows 10?

    Try to run the following command before the script:

           Set-ExecutionPolicy -ExecutionPolicy bypass


    SAAD Youssef


    Please remember to mark the replies as answer if they help, thank you!

    Friday, July 19, 2019 6:26 PM
  • SAAD Youssef,

    Thanks, but it did not work.  "Set-ExecutionPolicy -ExecutionPolicy bypass" ran fine, but I still received the same error.

    This script has worked in the past with Windows 1709, but I am now deploying 1809.  The only thing that I changed was the $ScriptPath variable so that the script can be more modular.  In the past the path was hard coded in.

    Friday, July 19, 2019 9:23 PM
  • I just ran the old script on a 1709 box and it is getting the same error.

    Import-StartLayout -LayoutPath 'D:\Install\!Standard Desktop Installers\LayoutModification.xml' -MountPath $env:SystemDrive\

    That's the old script.

    • Edited by Money Tree Friday, July 19, 2019 9:55 PM
    Friday, July 19, 2019 9:44 PM