Access Denied trying to cat a script?

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…

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

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.

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

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

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.