PSClassUtils icon indicating copy to clipboard operation
PSClassUtils copied to clipboard

Get-CUClassProperty Throws error when using -Path

Open Stephanevg opened this issue 7 years ago • 1 comments

The issue seems to come from the 'Resolve-PAth' cmdlet, as it points it to --> C:\Windows\system32\Tests\woop.psm1' instead of the real path (in .\Tests\woop.psm folder of the module)

>  Get-CUClassProperty -Path .\Tests\woop.psm1
Resolve-Path : Cannot find path 'C:\Windows\system32\Tests\woop.psm1' because it does not exist.
At C:\Users\taavast3\OneDrive\Repo\Projects\OpenSource\PSClassUtils\PSClassUtils\Functions\Public\Get-CUClass.ps1:72 char:56
+ ...             $ClassParams.Path = (Get-Item (Resolve-Path $Path).Path). ...
+                                                ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Windows\system32\Tests\woop.psm1:String) [Resolve-Path], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.ResolvePathCommand

Stephanevg avatar Nov 12 '18 08:11 Stephanevg

in the same direction:


[A][3] C:\Users\taavast3\OneDrive\Repo\Projects\OpenSource\PSClassUtils\PSClassUtils >
>  Get-CUClassProperty -Path ..\Tests\woop.psm1
Resolve-Path : Cannot find path 'C:\Windows\Tests\woop.psm1' because it does not exist.
At C:\Users\taavast3\OneDrive\Repo\Projects\OpenSource\PSClassUtils\PSClassUtils\Functions\Public\Get-CUClass.ps1:72 char:56
+ ...             $ClassParams.Path = (Get-Item (Resolve-Path $Path).Path). ...
+                                                ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Windows\Tests\woop.psm1:String) [Resolve-Path], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.ResolvePathCommand

Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At C:\Users\taavast3\OneDrive\Repo\Projects\OpenSource\PSClassUtils\PSClassUtils\Functions\Public\Get-CUClass.ps1:72 char:55
+ ...       $ClassParams.Path = (Get-Item (Resolve-Path $Path).Path).FullNa ...
+                                         ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand

You cannot call a method on a null-valued expression.
At C:\Users\taavast3\OneDrive\Repo\Projects\OpenSource\PSClassUtils\PSClassUtils\Classes\Private\06_CUClass.ps1:15 char:9
+         $this.Ast = $this.Raw.FindAll( {$args[0] -is [System.Manageme ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Stephanevg avatar Nov 12 '18 18:11 Stephanevg