vexx32 / PSKoans

A simple, fun, and interactive way to learn the PowerShell language through Pester unit testing.
GNU General Public License v3.0
1.73k stars 176 forks source link

Recursion on $home throws UnauthorizedAccessException - Local Issue #456

Closed DEberhardt closed 3 years ago

DEberhardt commented 3 years ago

Describe "Koan Bug, Issue, or Help Request"

AboutMeasureObject.Koans.ps1

Context "The Problematic Assertions"

Describe 'Measure-Object' {
    BeforeAll {
        $Numbers = @(
            839, 339, 763, 663, 238, 427, 577, 613, 284, 453
            850, 130, 250, 843, 669, 972, 572, 41, 172, 155
            729, 616, 285, 231, 128, 540, 204, 584, 407, 98
            668, 85, 320, 435, 87, 719, 936, 25, 75, 122
            665, 154, 943, 35, 391, 816, 420, 229, 3, 938
        )

        $Files = Get-ChildItem -Path $HOME -Recurse -Depth 2
    }

Line 20 ($Files = ...) fails for me with:

Invoke-Koan : Access to the path 'C:\Users\David\Intel\Logs' is denied.
At C:\Users\David\Documents\WindowsPowerShell\Modules\PSKoans\0.67.1\Public\Get-Karm
a.ps1:111 char:32
+                 $PesterTests = Invoke-Koan @{
+                                ~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\Users\David\Intel\Logs:String)
   [Invoke-Koan], UnauthorizedAccessException
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Invoke-Koan

Context "Your Attempts"

removed recursion to avoid unauthorizedAccessEception: $Files = Get-ChildItem -Path $HOME #-Recurse -Depth 2

Context "Additional Information"

None

DEberhardt commented 3 years ago

same in AboutWhereObject.Kaons.ps1

It 'also missing 3d vision ;)' { It 'can filter on object propertes' }

vexx32 commented 3 years ago

🤔 not sure how/why you'd be getting those exceptions? Get-ChildItem -Recurse -Depth 2 doesn't emit exceptions for me, even if there aren't two levels for it to go into?

Looks like you may have some odd files in your user folder that are locked, which is pretty unusual...

Probably the ideal here would be to setup an ephemeral collection of temp files for the koan to work with.

DEberhardt commented 3 years ago

$Home is targeting my user folder, maybe it is a local issue... I went and removed this directory... must be an old relic from somewhere. The error is now gone. I also tested with $PSHOME which did work as well...

Close?

vexx32 commented 3 years ago

Aye, I'll close it for now. Eventually we need to sort out #183 and this should go away as a possible issue then as well. 🙂