Get Custom Variable from Powershell / Command line

Comments

5 comments

  • Colby Bouma

    At this time we do not have a command to retrieve variables. You can retrieve them from the database, but please be careful.

    1
    Comment actions Permalink
  • F V

    :-(

     

    Would be nice to add it, shouldn't be too complex since you already have updatecustomevariable but i know your roadmap depends on many factors ...

    Since I was kind of expecting this answer I already found a dirty workaround : 

    i put the custom variable in the description of one collection then i use pdqinventory.exe getCollection mycollection to retrieve the collection details and there i get my custom variable value in the description, just have to do a little string "cleanup" 

     

     

     

     

    1
    Comment actions Permalink
  • Colby Bouma

    Ooh, that's a neat workaround!

    1
    Comment actions Permalink
  • Paul Michael

    Apologies i know this is an oldish post but we use powershell to run a Get command to pull version information off of our in house built applications and update the variable fields in PDQ inventory, i'm not sure if that's what your looking to do or try something similar, but we have had it for a while now and thought i should share as it may be of use.

    a quick run down of what we have done if its of any use to you is first as we scan MSI's we installed https://www.powershellgallery.com/packages/MSI/3.2.33

    then we manually run the script below to pick up cahnges in the MSI files which will also update the custom variable in PDQ inventory, once a scan has been run and version have changed we move applications to an out of date folder which is picked up by PDQ deploy to go an update these clients.

    #"$AppPath = Get-child Z:\Programs and Drivers\apps

    $PDQHome = "\\pdq\Programs and Drivers\apps"
    #$Foldernames = Get-ChildItem '\\pdq\Programs and Drivers\apps' | Select name # Line to autmatially pickup foldernames from location
    #specify's folders by name below:
    $Foldernames = 'app1','app2','app3'

    ForEach($Foldername in $Foldernames){
    #.name is required if automatially picking up foldernames
    $FP = $Foldername#.Name
    $MSI = (Get-ChildItem "\\pdq\Programs and Drivers\apps\$FP" | Where-Object {$_.name -Like "*.msi"} | Select Name).name
    $FullPath = $PDQHome + '\' + $FP + '\' + $MSI
    $ProductVersion = Get-MSIProperty -path $FullPath -property ProductVersion
    $Productname = Get-MSIProperty -path $FullPath -property ProductName
    PDQInventory.exe UpdateCustomVariable $Productname.Value $ProductVersion.Value
    }

    0
    Comment actions Permalink
  • F V

    Thanks for your contribution but as I stated I was trying to GET a custom variable current value, not SET it.

     

    0
    Comment actions Permalink

Please sign in to leave a comment.