Access Denied trying to cat a script?

This topic contains 5 replies, has 2 voices, and was last updated by  paul peters 2 years, 5 months ago.

  • Author
    Posts
  • #25046

    paul peters
    Participant

    Why am I getting and access denied? I must not be able to see the forest through the trees.

    PS C:\utils\scripts\powershell\module2> cat .\1Var.ps1
    cat : Access to the path 'C:\utils\scripts\powershell\module2\1Var.ps1' is denied.
    At line:1 char:1
    + cat .\1Var.ps1
    + ~~~~~~~~~~~~~~
    + CategoryInfo : PermissionDenied: (C:\utils\script...odule2\1Var.ps1:String) [Get-Content], UnauthorizedAccessException
    + FullyQualifiedErrorId : GetContentReaderUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetContentCommand

    PS C:\utils\scripts\powershell\module2> get-acl .\1Var.ps1

    Directory: C:\utils\scripts\powershell\module2

    Path Owner Access
    —- —– ——
    1Var.ps myDomain\me mydomain\me Allow FullControl...

  • #25052

    Richard Siddaway
    Moderator

    Can you run the script?

    Have you tried opening the script in ISE?

    Is there anything odd in the security settings for the script – open properties in file explorer

  • #25089

    paul peters
    Participant

    I cannot run the script or open it in ISE. I had to unblock the script but I don't see anything odd in security. I gave myself full access to the entire directory it is in.

  • #25128

    Richard Siddaway
    Moderator

    Can you open the script in notepad? Is it actually PowerShell code?

  • #25152

    paul peters
    Participant

    It is powershell code. i can open it in notepad but not in ISE.

  • #25156

    paul peters
    Participant

    Solution found. it wasn't until I looked at the files in windows explorer that I saw an issue. The file and folder names were green. I removed the "Encrypt contents to secure data" in the advanced properties. I am not sure how that happened but they were zipped up from an instructor. Now everything works as expected.

You must be logged in to reply to this topic.