Return Value from Get-NAVAppInfo powershell

jimmyfjimmyf Member Posts: 104
Is it possible to wrap Get-NAVAppInfo powershell command in a function to return certain values. For example the Synch state and the installation status?

Thanks you

Best Answer

Answers

  • TallyHoTallyHo Member Posts: 417
    edited 2020-05-07
    Yes, I created powershel script once to get the content of the Version tag:

    [xml]$xmlFile = Get-NAVAppInfo -Name 'MyApp' -ServerInstance 'BC140' | ConvertTo-Xml
    $SelectedNode = [xml]$xmlFile | Select-XML -XPath "//Property[@Name='Version']" | Select-Object -ExpandProperty "node"
    $TheVersion = $SelectedNode.InnerText
  • DenSterDenSter Member Posts: 8,307
    You can also load a JSON object and access its members directly.
    $MySettings = (Get-Content '.\PowerShell\MySettings.json') | ConvertFrom-Json
    $AppJSON = (Get-Content (Join-Path $MySettings.AppFolder '\app.json')) | ConvertFrom-Json
    
    First this loads a JSON object that includes a member 'AppFolder', and in the second line I load app.json from my app folder. From there I can then access for instance the publisher by using $AppJSON.publisher.

    Not sure if Get-NAVAppInfo loads the app information directly but you'd have to play around with it to make that happen
  • TallyHoTallyHo Member Posts: 417
    @DenSter:
    So please provide a working solution for Get-NAVAppInfo result processing this way.
    I know how to convert a json file to powershell object, but using it this way
    could make you end up with a complex type json.. that's what I remember encountering
    trying to tackle this problem. So I choose the xml option as the best way to go.
  • DenSterDenSter Member Posts: 8,307
    DenSter wrote: »
    Not sure if Get-NAVAppInfo loads the app information directly but you'd have to play around with it to make that happen
    You must have missed the last sentence in my reply there.

  • TallyHoTallyHo Member Posts: 417
    edited 2020-05-07
    No, got it all the first time.
    Just hoped you could show us the playing around part. At least that would have contributed something.
  • DenSterDenSter Member Posts: 8,307
    edited 2020-05-07
    TallyHo wrote: »
    At least that would have contributed something.
    Are you still mad at me?

    I posted that for Jimmy, not you. I know you already know everything
  • TallyHoTallyHo Member Posts: 417
    edited 2020-05-07
    Been trying to get it done in json, but this doesn't work. So I was hoping you'd shed some more light here to spare Jimmy my fate. Sincere disappointment.. still.
  • DenSterDenSter Member Posts: 8,307
    edited 2020-05-07
    You know, instead of insulting me, you might want to try asking in a friendly way next time, you get way more done that way. I put this together for Jimmy, because I think it may help him, instead of slogging through XML

    You actually don't need a Json object. You can just read the output into a psobject and browse through them
    s5jewcd4m6w1.png
  • TallyHoTallyHo Member Posts: 417
    edited 2020-05-07
    I was asking nicely, you replied arrogantly.
    As it was last time.

    Good one! Spared Jimmy a lot of json hussle.
  • DenSterDenSter Member Posts: 8,307
    edited 2020-05-07
    TallyHo wrote: »
    At least that would have contributed something.
    That's not asking nicely, that is meant to insult me

    And you're welcome by the way, I know you meant to say thank you because you are such a nice guy

  • TallyHoTallyHo Member Posts: 417
    You're right. At that point I had stopped asking friendly. But hey screw the process, it's the results that count.
  • DenSterDenSter Member Posts: 8,307
    edited 2020-05-08
    The way people treat me is not what motivates me though, so your 'process' is not what got the results
Sign In or Register to comment.