Jump to content

AnEngelsen

Members
  • Posts

    62
  • Joined

  • Last visited

  • Days Won

    9

Posts posted by AnEngelsen

  1. Here is the final result (for all you Windows users).

    $customFieldName = $Env:CF_Name
    $flag = $Env:CF_Value
    $id = $Env:ClientID
    $server = (Get-ItemProperty -Path REgistry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\FileWave\WinClient).server
    $token = $Env:apitoken
    
    $header = @{Authorization=$token}
    $api = "https://" + $server +  ":20445/inv/api/v1/custom_field/set_association"
    $data = '{"client_ids" : [' + $id + '], "fields" : {"' + $customFieldName + '" : ' + $flag + '}}'
    
    Invoke-RestMethod -Method POST -Headers $header -Body $data -ContentType application/json -Uri $api
    exit 0

    You will need to set (4) environment variables. (See attachment)

    Make sure to set the ClientID variable to %filewave_id%. (Not %device_id%)

    Associate the fileset to a Client or a Client Group. Then perform a model update. Enjoy!

    Screen Shot 2022-09-28 at 14.28.16.png

    • Thanks 1
  2. Lol. Wow! I feel dumb.

    This whole time I was trying to run the API call using the ID of a client clone object. As soon as I replaced the ClientID with the ID of the original client object (what's listed in the `Device Details` tab, the script started working great!

    Live & learn!

    • Like 1
  3. @Pierre-Nicolas Sorry. That was a copy & paste fail on my part. You're right, you 💯 need to remove the trailing forward slash from the Server URL.

    Then, when you run the PS1 script you get no error message. 👍🏻 However, when you review the custom field association (within FileWave Admin); the Custom Field is not associated to the target device. 👎🏻(See attachment)

    Screen Shot 2022-09-28 at 13.36.51.png

  4. Many Thanks @Pierre-Nicolas!

    I was able to use this syntax to create the following shell script.

    #!/bin/bash
    
    #Set the following environment variables (within the fileset's executable tab): apitoken, clientID, customFieldName, flag
    
    #ENV variable advice...
    #   customFieldName: Use the "Internal Name" which can be found in the Assistants --> Custom Field menu in FileWave Admin.
    #   flag: true or false
    #   clientID should be set to %filewave_id%
    
    serverURL="https://lifeisgood.filewave.net:20445/inv/api/v1/custom_field/set_association"
    
    curl -X POST $serverURL \
      -H  "accept: application/json" \
      -H  "Authorization: $apitoken" \
      -H  "Content-Type: application/json" \
      -H 'cache-control: no-cache' \
      -d "{\"client_ids\" : [$clientID], \"fields\" : {\"$customFieldName\" : $flag }}"
    #JSON data without using variables:     -d "{\"client_ids\" : [3092211, 123, 77],\"fields\" : {\"printNode_computerID\" : true}}"
    
    exit 0

     

    I would also love to create a Windows-friendly fileset. However, I'm having issues creating a fully-functional PowerShell script. Currently, the script does not produce an error message. However, when I check FileWave Admin, I can see that the custom field is not being associated to the target device.

    My suspicion is that I'm experiencing a syntax-related issue with the line that contains the JSON Data. Can someone help me correct my $data payload?

    $server = "FQDN_GOES_HERE"
    $token = "API_Token_GOES_HERE"
    $customFieldName = "CF_Name_GOES_HERE"
    
    $api = "https://" + $server +  ":20445/inv/api/v1/custom_field/set_association/"
    $header = @{Authorization=$token}
    $date = Get-Date -Format "o"
    
    #Data (Attempt 1)
    #REPLACE CLIENT ID!
    $flag = 1
    #$data = '{"client_ids" : [3092254], "fields" : {"' + $customFieldName + '" : {"exitCode":null,"status":0,"updateTime":"' + $date + '","value":"' + $flag + '"}}}'
    
    # Data (Attempt 2)
    #REPLACE CLIENT ID!
    $flag = "true"
    $data = '{"client_ids" : [3092254], "fields" : {"' + $customFieldName + '" : ' + $flag + '}}'
    
    Invoke-RestMethod -Method POST -Headers $header -Body $data -ContentType application/json -Uri $api
    exit 0

     

  5. @jdamhoff

    TLDR: I recommend creating a Fileset revision.

    *********

    Full Explanation: The "default" revision is used by the majority of your devices. Other (new) revisions should be associated to a handful of beta devices, until you confirm that the new revision is "stable". Here's how to 'get started' with revisions:

    1. Launch FileWave Admin (desktop app).
    2. Click and drag the new version of Chrome.app on top of your existing Chrome fileset.
    3. Choose Add revision to existing.
    4. After the file upload completes, select the fileset. Then click the `Properties` button (top of window).
      1. Click the `Manage Revisions` button.
      2. Give the new revision a better name. (such as v105.0.5195.125)
      3. Click OK to confirm. Click OK again.
    5. Create an association between the Chrome fileset and your "Beta" device(s).
      1. When you create the association you will be prompted to select a fileset revision. Choose your newly-created revision.
      2. Update the model.
    6. When you're ready for everyone to start using the new revision:
      1. Select the Chrome fileset.
      2. Click the `Properties` button (top of window).
      3. Click the `Manage Revisions` button.
      4. Select the fully-tested revision.
      5. Click the `Set as default` button.
      6. Click OK to confirm. Click OK again.
      7. Update the model.
    • Thanks 1
  6. If I don't want to associate a custom field to "all devices", I can right-click on a client (or client group) within the Native Admin and manually associate a custom field to a device/group.

    However, has anyone found a way to use the FileWave API to associate a custom field to a device? According to the API documentation, there should be 0 parameters required to execute:

    https://FQDN:20445/inv/api/v1/custom_field/set_association

    (But that's simply not the case)

    Screen Shot 2022-09-26 at 9.31.29 PM.png

×
×
  • Create New...