Important Notice: On February 29th, this community was put into read-only mode. All existing posts will remain but customers are unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

Get Custom Variable from Powershell / Command line

Hi, 

 

is it possible to GET a custom variable value from PowerShell / command line ?

 

I know I can UPDATE one with updatecustomevariable but i ant to GET the value, not update it.

 

thanks

 

2

Comments

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

    1
  • :-(

     

    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
  • Ooh, that's a neat workaround!

    1
  • 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
  • Thanks for your contribution but as I stated I was trying to GET a custom variable current value, not SET it.

     

    0
  • I just added Get-PdqVariable to PdqStuff (version 2.0.0), a PowerShell module I created.

    Install-Module -Name 'PdqStuff'
    Import-Module -Name 'PdqStuff'
    Get-PdqVariable -Product 'Inventory' -Name '@(FavoriteBurger)'
    0
  • Nice job Colby, very tidy code may I add :-)

     

    0
  • Thanks!

    0