Loading

Powershell

Skip Feed
  1. Some customers may have a need to add custom contextual data to their IT Visibility devices (for example, you might want to associate the assigned user to each of your inventory devices) or to Software Products in Technopedia (for example, you might want to label specific applications as being "preferred" or "prohibited", etc.). To enable this, Flexera has a Contextual Data Store API. However, this may not be the easiest API to use, especially if you're just starting out. To try to make this easier to use, I have created a PowerShell script and a couple modules that wrap this API into simple cmdlets and a basic guided user experience. It can be run interactively with some basic UI or completely automated for scheduled uploads using command line parameters.

     

    I'm still working on the comment-based help and some more detailed instructions, but I've had a few people asking for this, so I wanted to get it posted in its current state, so others can use it. I welcome feedback and contributions from the community, so please feel free to make suggestions for improvements. At some point, I hope to get this published in GitHub to make it easier to share updates and allow the community to contribute their own enhancements, but for now, here it is.

     

    Instructions:

    You'll need to download the attachments into a folder and modify the Upload-ContextData.config file with your own settings. Specifically, uncomment the appropriate RegionTLD setting (stands for Region Top Level Domain) that matches the region where your Flexera One org resides (com for North America, eu for EMEA, or au for APAC). Simply remove the # in front of the setting you want to use and make sure the other RegionTLD lines have the # in front of them. For example, if my Flexera One org resides in EMEA, my settings would look like this...

     

    #RegionTLD=com

    RegionTLD=eu

    #RegionTLD=au

     

    Next, make sure you update the OrgID to match your organization ID. This is the numeric value that appears in the address bar after /orgs/ like this...

     

    https://app.flexera.au/orgs/12345/landing

     

    All other settings in this config file are optional. Here is the full list:

    • DebugLogging - not really implemented
    • FileRetentionDays - Each run of the script creates a new log file. This setting controls how long to retain those logs. A negative value will retain all logs indefinitely. A value of 0 will remove all previous logs each time you run the script. A positive value will delete any previous logs older than the specified number of days each time you run the script.
    • RegionTLD - already discussed above. Either com (North America), eu (EMEA), or au (APAC)
    • OrgID - already discussed above. Needs to match your Flexera One org ID
    • MaxRetries - specifies the number of times to retry an API call if it fails
    • RetryIntervalSeconds - specifies how many seconds to wait in between retries if MaxRetries is greater than 0
    • SmtpServer - specifies an SMTP relay server that can be used to send email messages
    • SmtpPort - specifies the port number to be used for sending email through the SMTP relay server
    • UseSSL - specifies if SMTP communication should enforce SSL (TLS) encryption
    • MailFrom - specifies the sender email address
    • MailTo - specifies one or more email addresses to send email messages to (semi-colon delimited)
    • EnableFailureEmail - Boolean value specifying if an email message should be sent when a failure occurs
    • EnableSuccessEmail - Boolean value specifying if an email message should be sent when the script runs successfully without errors

     

    Note: the Send-Email function only works if you have an internal SMTP relay that supports basic authentication. However, the Send-Email function does not currently support M365/Exchange Online with its recent requirement for modern authentication.

     

    After you've configured your settings, you can run the Upload-ContextData.ps1 script. Running it without any command line parameters will prompt you for the needed information and guide you through the process to create a new contextual data source or to upload a contextual data file. The first time you run the script, you'll also be prompted to enter your Refresh Token for authentication with Flexera One. If you don't already have a refresh token, you'll need to generate one. This token will be encrypted and stored in a file in the same folder with your script and will be used to automatically authenticate on subsequent runs of the script. This encrypted file is specific to the user running the script and the system on which the script is being run. It cannot be used or decrypted by any other user or on any other system.

     

    Note: This PowerShell module was written to support either user-based Refresh Token authentication or service account-based Client Credential authentication; however, the API does not currently support the service account-based Client Credential authtentication. This is being worked on in Q1 2025, and once the API supports it, the script will be able to use it without modification. You'll just need to delete your CRED file and run the script again to choose the Client Credential option.

     

    That's it for now. I hope you find this useful.

    Expand Post

  2. Does anyone know on what basis powershell scripts running with the agent are detected?

    Hi all,

     

    The agent's running scripts are displayed as part of its package. However, when the script is not running, it is not detected even though it is on the computer. 

    Does the script add a value to the agent which confirms that the script has been used?

     

    Kind regards

    Expand Post

    1 of 6
    • There were some recognitions missing for the new scripts coming with the new Windows agent 7.0.0 version. But this is fixed in the meantime and now they show as Axel writes in the Inventory Admin console and SLM web-interface.

  3. Software Uninstallation using Snow AP SLM reharvest task

    Hi Folks,

     

    I have a doubt regarding software uninstallation using the Snow AP SLM reharvest task.

     

    How can we confirm that the Snow AP is uninstalling the application? As I observed that it is removing username/hostname from security groups. It is not uninstalling software from Control Panel\Programs\Programs and Features. We have created this security group to install and uninstall applications from the software center.

     

    We have received the "Remove object from group" script through the Automation book. This is the only script available for uninstallation.

     

    Do we need to write another script to uninstall the software from Control Panel\Programs\Programs and Features?

    Expand Post
    Question with a best answer.

    Best Answer

    Hi,

     

    The out-of-the-box re-harvest only removes a computer or user from the specified AD group. We then assume that your SCCM is setup to act on this action. This can be achieved by setting up a query based collection in SCCM. Now, I am in no way an SCCM expert and really cannot help with that. You should probably talk to your team responsible for deployments.

     

    Some customers do not have query based collections, instead they have specified specific uninstall collections instead - meaning that they have to modify the out-of-the-box behavior.

     

    So, it's a bit hard to give a straight answer because it depends on your current setup.

     

    I did find a document that describes the query based sccm approach

    Expand Post
    Community Manager by Community Manager (Flexera Software)

    • Community Manager (Flexera Software)

      Hi!

       

      AP is not responsible for the actual uninstall. AP removes the object from the AD group. You have to setup your SCCM (or other deployment tool you use) to act on that removal. This probably includes building an uninstall package for example.

       

      Hope that clears things up for you!

       

      //Joakim

      Expand Post

  4. How can we fetch DL using the PowerShell script in the Snow AP?

    Hi Folks,

     

    How can we fetch DL using the PowerShell script in the Snow AP? Also, want to grade out the secondary approval field in the SNOW AP.

     

    Is it possible to complete this activity?

     

    Regards,

    Ashish

    Expand Post
    Question with a best answer.

    Best Answer

    Hi

     

    Short answer: Absolutely

     

    Long answer: Write a powershell function that does what you want. Reference it from the admin gui and use the results and display it for the user. And regarding hiding parameters from the checkout, just uncheck "Checkout" on the parameter

     

     

    Expand Post
    Community Manager by Community Manager (Flexera Software)

    • Community Manager (Flexera Software)

      Hi

       

      Short answer: Absolutely

       

      Long answer: Write a powershell function that does what you want. Reference it from the admin gui and use the results and display it for the user. And regarding hiding parameters from the checkout, just uncheck "Checkout" on the parameter

       

       

      Expand Post
      Selected as Best

  5. Is there a guide, directions, or detail on the suggested/expected patterns to be used in the PowerShell Custom scripts?

    I've perfected the PS commands that yield the desired information, which in this case is the physical Harddrive's Name, SerialNumber and Tags. I've tested the PS1 script as well as the encrypted version which does pipe the desired information to the cmdline; however, when I review the logs it presents a 'PowerShell exited with error code 6'.

     

    I suspect, that the results the agent is expecting are:

    (1) Data (nVarchar),

    (2) ModifiedTime(Datetime2),

    (3) Name(nVarchar),

    (4) RegKey(nVarchar),

    (5)Type (int).

     

    But I'm unsure how to actually declare those. Does anyone know? Maybe @Oliver Berger​  or @Detlev Eufinger​ @Ester_locked Memoli(Retired)​ ?

     

    If Snow can provide me with the pattern or expected outputs that agent can use, I will offer to compose a guide for the community to use as well as share materials :)

    Expand Post

    1 of 5
    • Any information you can provide would be helpful. I am also trying to create a custom script but unsure how to store/return the data the script collects. I was given the attached template which contains functions Yield-Software & Yield-RegistryKey but it seems like those are only used to store data about the script itself. It would be helpful to see the code of one of the scripts in the repository mentioned here: https://community.flexera.com/s/article/Release-notes-Snow-Inventory-Script-Repository-260?tabset-1909e=2

      Expand Post
      • Unknown file type
        The file is no longer available.

  6. Hi Automation Platform administrators and developers!

     

    Just wanted to share a new KB Article with some tips and tricks for building and troubleshooting AP activities!

     

    Found here:

    https://community.flexera.com/s/article/Building-and-troubleshooting-AP-activities-in-PowerShell-ISE

     

    Comment if you find it useful, or if you think anything is missing!

     

    Hope this helps!

     

    //Oskar

     

    Expand Post

  7. Is there anywhere which details all of the official "Snow Inventory PowerShell scripts"?

     I know there are 4-6 official ones, but it would be good to have a repository somewhere in the community of the official ones, their versions, what they they bring back, etc. Some have been out there, but not distributed via SUS for community to use like the Autodesk one, but really no Autodesk report in SLM (yet), or the one which fixes Lenovo models.


    1 of 5
    • The link is not working. Could this be fixed please ?

End of Feed
8 Chatter Feed Items
ALL CONVERSATIONS
UNSOLVED
ARTICLES
Loading
Powershell | Flexera