Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If a property begins with a '#' character, this kills Show-object #2

Open
1RedOne opened this issue Nov 17, 2015 · 0 comments
Open

Comments

@1RedOne
Copy link

1RedOne commented Nov 17, 2015

Found a weird one.

[xml]$xml = wget https://patchmypc.net/category/SCUPCatalogChanges/feed
Show-Object $xml

This object has a property which is named '#comments', and Show-object runs into the following error when trying to parse this:

Invoke-Expression : At line:1 char:20

  • $resultObject = $a.#comment
  •                ~
    
    Missing property name after reference operator.
    At C:\Program Files\WindowsPowerShell\Modules\PowerShellCookbook\1.3.3\PowerShellCookbook.psm1:7648 char:9
  •     Invoke-Expression "`$resultObject = $nodePath"
    
  •     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : ParserError: (:) [Invoke-Expression], ParseException
    • FullyQualifiedErrorId : MissingPropertyName,Microsoft.PowerShell.Commands.InvokeExpressionCommand

The variable '$resultObject' cannot be retrieved because it has not been set.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellCookbook\1.3.3\PowerShellCookbook.psm1:7651 char:36

  •     PopulateNode $selectedNode $resultObject
    
  •                                ~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (resultObject:String) [], RuntimeException
    • FullyQualifiedErrorId : VariableIsUndefined

The code in question

## Walk through its parents, creating the virtual
        ## PowerShell syntax to access this property.
        $nodePath = GetPathForNode $selectedNode 

        ## Now, invoke that PowerShell syntax to retrieve
        ## the value of the property.
        Invoke-Expression "`$resultObject = $nodePath"

        ## And populate the node with the result object.
        PopulateNode $selectedNode $resultObject
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant