Stephanevg / PSClassUtils

A set of utilities to work with Powershell Classes
http://powershelldistrict.com/how-to-generate-a-uml-diagram-using-powershell/
92 stars 23 forks source link

Get-CUClassProperty Throws error when using -Path #62

Open Stephanevg opened 5 years ago

Stephanevg commented 5 years ago

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 commented 5 years ago

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