Author Posts

May 8, 2015 at 6:44 am

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...

May 9, 2015 at 2:29 am

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

May 11, 2015 at 7:04 am

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.

May 12, 2015 at 8:32 am

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

May 13, 2015 at 4:56 am

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

May 13, 2015 at 5:34 am

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.