A new Flexera Community experience is coming on November 25th. Click here for more information.
Is it possible to run a PowerShell script that will update records in the FNMS cloud? We are trying to automate as many things as possible. Some of the things that we want to automate include setting the Active/Ignored inventory flag, and setting the Role of the inventory. Ideally we want to read data from the FNMS cloud via an API, process it locally, and then where required call an API to update the data element in the FNMS cloud.
Apr 10, 2019 10:00 AM
Steven,
Thanks for the feedback.
Jason
Apr 11, 2019 09:12 AM
FlexNet Manager Suite Cloud and On-premises does have an internal API that other Flexera products (like App Portal) make use of. However it is not documented, supported or guaranteed to remain unchanged over future product updates. So it is not very effective for your own production use.
With those major caveats stated, if you still want to try a scripted extraction of data from FlexNet then the GetCustomView API may be useful. The attached sample PowerShell script could be used as a starting point.
Here is help information for the script:
PS C:\Temp> Get-Help .\GetCustomView.ps1 -Detailed NAME C:\Temp\GetCustomView.ps1 SYNOPSIS Sample script to illustrate calling the GetCustomView FlexNet Manager Suite web API to retrieve results from a report. SYNTAX C:\Temp\GetCustomView.ps1 [-ReportID] <Int32> [[-BearerToken] <String>] [[-TenantUID] <String>] [[-SearchString] <String>] [[-RowLimit] <Int32>] [[-FNMSSite] <String>] [<CommonParameters>] DESCRIPTION This script is a sample illustrating use of the GetCustomView FlexNet Manager Suite web API to retrieve results from a report that has been configured in the web UI. The "FNMP API integration" option must be enabled for your FlexNet Manager Suite license key to be able to make use of the web API. Be aware that the web API it is not documented, supported or guaranteed to remain unchanged over future product updates. This script has not been tested in a scenario where SSO using a SAML identity provider is enabled. Feedback is welcome on whether the script works in such a configuration, or what may need to be changed to get it to work. This script is provided as a sample as-is without support or warranty of any kind. PARAMETERS -ReportID <Int32> The numeric (integer) ID of the report to extract data from. This ID can be obtained from the number in the URL used to view the report in the web UI. -BearerToken <String> The bearer (or "access") token for the FlexNet Manager Suite Cloud service account to be used for authorization. A bearer token can be obtained by going to Accounts > All Accounts > Create an account > Service account in the web UI. Adda new account, and the token will be displayed once when the account is created. Be sure to remember the token, as once you navigate away from the page it is impossible to retrieve the token. If you forget the token you need to create a new service account to get another token. This parameter is not required when accessing an on premises FlexNet Manager Suite instance. -TenantUID <String> The FlexNet Manager Suite tenant UID identifying the subscription to connect to. Contact Flexera Support for your tenant UID if you do not know it. This parameter is not required when accessing a single-tenant on premises FlexNet Manager Suite instance. -SearchString <String> Text to search for in order to filter and limit the results returned. Default: Not set (no filtering will occur). -RowLimit <Int32> The maximum number of rows to return. Avoid using large values, as this API is not intended to expose massive data sets. Default: 100 -FNMSSite <String> The URL for your FNMS instance. This is typically either https://www.flexnetmanager.com (the default) or https://www.flexnetmanager.eu when using FlexNet Manager Suite Cloud. It is the URL of your FlexNet Manager Suite web application server for an on premises installation. <CommonParameters> This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable. For more information, see about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216). -------------------------- EXAMPLE 1 -------------------------- PS C:\>$result = .\GetCustomView.ps1 -FNMSSite https://myco.flexnetmanager.com -BearerToken 01234567-89ab-cdef-0123-456789abcdef -TenantUID ABCDEFGHIJKLMNOP -ReportID 2698 -Verbose Retrieves data from the report you can view interactively at https://myco.flexnetmanager.com/Suite/Reports/View/2698 in the identified FlexNet Manager Suite Cloud tenant into the variable $result. Verbose diagnostic information is output to the PowerShell window. -------------------------- EXAMPLE 2 -------------------------- PS C:\>.\GetCustomView.ps1 -BearerToken 01234567-89ab-cdef-0123-456789abcdef -TenantUID ABCDEFGHIJKLMNOP -ReportID 99 -SearchString Acrobat -RowLimit 100 -FNMSSite https://myco.flexnetmanager.eu -Verbose | ConvertTo-Csv -NoTypeInformation | Out-File ".\GetCustomView.csv" Saves up to 100 rows of data retrieved from the report with ID 99 in the identified FlexNet Manager Suite Cloud (EU instance) tenant to the CSV file GetCustomView.csv. -------------------------- EXAMPLE 3 -------------------------- PS C:\>.\GetCustomView.ps1 -ReportID 99 -RowLimit 10000 -FNMSSite http://fnms01.internal.acme.com -Verbose | ConvertTo-Csv -NoTypeInformation | Out-File ".\GetCustomView.csv" Saves up to 10000 rows of data retrieved from the report with ID 99 from the identified on premises FlexNet Manager Suite installation to the CSV file GetCustomView.csv. Authentication to FlexNet Manager Suite is done as the currently logged in user. REMARKS To see the examples, type: "get-help C:\Temp\GetCustomView.ps1 -examples". For more information, type: "get-help C:\Temp\GetCustomView.ps1 -detailed". For technical information, type: "get-help C:\Temp\GetCustomView.ps1 -full".
As @steven_donovan1 has suggested, using a business adapter to do updates of data in the FlexNet system is a great approach. The Business Adapter Practice Guide is a good place to start for learning about adapters.
Apr 10, 2019 09:47 PM - edited Jul 16, 2019 10:43 PM
Chris,
Appreciate the response. Out of curiosity, is there an API that can be used to update records in the FNMS cloud?
Thanks,
Jason
Apr 11, 2019 09:13 AM
The only mechanism at this time to update records in the cloud is the Business Importer provided in the FlexNet Beacon. This provides the appropriate mapping of the source to destination fields\objects. This keeps the data integrity in tact.
Apr 11, 2019 03:37 PM
Apr 12, 2019 04:00 PM
I'm trying to get the report data via PS, but the returned result is zero records. I've provided the report id, tenant uid, bearer-token. I'm not getting any errors, but the result is still zero records.
When I go to the report via WebUI, I can see the report, thought to get the results I need to "run" it (like any other custom created report). The report returns results as it should be.
I'm a little lost here, any advice on how to troubleshoot this issue?
Verbose output:
VERBOSE: Calling web API at https://COMPANY.flexnetmanager.com/ManageSoftServices/ComplianceAPIService/ComplianceAPIService.asmx VERBOSE: VERBOSE: SOAP request: VERBOSE: <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/"> <soap:Body> <tem:GetCustomView> <tem:customViewID>5173</tem:customViewID> <tem:rowLimit>10</tem:rowLimit> <tem:tenantUID>ABCDEFGHIJKL</tem:tenantUID> </tem:GetCustomView> </soap:Body> </soap:Envelope> VERBOSE: VERBOSE: POST https://COMPANY.flexnetmanager.com/ManageSoftServices/ComplianceAPIService/ComplianceAPIService.asmx with -1-byte payload VERBOSE: received 2133-byte response of content type application/soap+xml; charset=utf-8 VERBOSE: Count of records returned: 0
Thanks,
Oct 10, 2019 04:45 AM
Hi,
Try using a a content-type of text/xml
Regards
Kim
Oct 10, 2019 07:38 AM
Hi,
Thanks for the suggestion. I've looked into the script file and see that the content type is already set to text/xml.
My line 109 says:
$result = Invoke-WebRequest -Uri $url -Headers $headers -Method Post -UseDefaultCredentials -ContentType "text/xml" -Body $soapRequestBody
I see that the response comes as:
VERBOSE: received 2133-byte response of content-type application/soap+xml; charset=utf-8
Thanks,
Oct 10, 2019 07:54 AM
It say that it returned 2133 bytes , what is in that response ?
There should be something that indicate what is going on ...
Here is a Body that I know works . you need to change the report id 😉
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/"> <soap:Body> <tem:GetCustomView> <tem:customViewID>8605</tem:customViewID> <tem:rowLimit>100000</tem:rowLimit> </tem:GetCustomView> </soap:Body> </soap:Envelope>
Regards
Kim
Oct 10, 2019 08:03 AM
It is possible that the service operator account the bearer token ID is from is not in any roles that would grant access to the data you would expect to see in the report? If the role membership of the operator account is different from the role membership of the account you use for interactively accessing the UI then that could explain different results.
Oct 12, 2019 09:49 PM
That was it!
I've given the Operator rights to the account to test the suggestion, and it works. I'll fine-tune the access rights now.
Thank you very much.
Oct 16, 2019 06:22 AM
Hi Chris,
Can the GetCustomView script be extended to support custom views in addition to custom reports? I'm trying to generate alerts about failed system tasks and the best I can do on FNMS Cloud is create a custom view of the System Tasks page.
Thanks!
Jan 06, 2020 02:09 PM
@ticalotta - the API can only be used to access data that is exposed in reports sorry. It cannot be used to get data shown in other pages in the UI.
Jan 06, 2020 08:11 PM
Darn. Thanks for confirming.
Jan 07, 2020 08:12 AM
I see creating a bearer token is required for cloud which can be obtained by going to Accounts > All Accounts > Create an account > Service account in the web UI. Adda new account, and the token will be displayed once when the account is created.
I don't a reference to service account in the web UI, am I missing something?
Thanks
Craig
Apr 14, 2020 05:19 PM
Here is a screenshot of how the option to add a service account should look:
If you don't see this then maybe you don't have appropriate rights, or possibly you need to reach out to your Flexera Account Manager to get a FlexNet Manager Suite license that supports API access.
Apr 14, 2020 08:51 PM
This is nice to have, but I just wish it was supported.
For some reason, there are fields that I can't pull down from custom reports when running this. It's unfortunate that there still ins't a true solution for automation and distribution of these reports.
Mar 23, 2020 02:21 PM