Jump to content

Powershell API module issue


Recommended Posts

Hi @Giuseppe Iannacone,

I'm not absolute sure, but the error message suggests that somehow $h_id isn't set correctly. What happens if you output $h_id separately.

Another item of note: "entityBrowseRecords" has been marked as "deprecated" for a while. You might want to look into using "entityBrowseRecords2" instead.

 

Link to comment
Share on other sites

Hi @Giuseppe Iannacone,

This is basically saying that the value in your $h_id varible is null, and you can't .Trim() a null. This would suggest that either no records have been returned by your call to entityBrowseRecords, or more than one has (so row would be an array of PSObjects rather than a flat PSObject), in which case you need to handle either of those outcomes in your script.

Cheers,

Steve

Link to comment
Share on other sites

Hi @Giuseppe Iannacone,

I've just given this a whirl, the HornbillAPI module is working as expected, but there are a number of issues with your script - all calls to Open-Element, Close-Element and Add-Param should be replaced by the correct cmdlets: Open-HB-ElementClose-HB-Element and Add-HB-Param otherwise you wont be sending any payload to the API.

I wrote the following very basic script as an example, using v1.1.0 of the Hornbill API module, which searches for an exact match and includes some very basic handling of when a record is not found. This is when it's successfully found a matching asset:

image.png

And when an asset record is not returned:

image.png

Hope this helps,

Steve

Link to comment
Share on other sites

Hi @Giuseppe Iannacone,

The latest versions of the HornbillAPI and HornbillHelpers modules can be viewed in the PowerShell Gallery:

https://www.powershellgallery.com/packages/HornbillAPI/1.1.0

https://www.powershellgallery.com/packages/HornbillHelpers/1.1.1

From PowerShell, run the following commands:

Install-Module -Name HornbillAPI
Install-Module -Name HornbillHelpers

And this will install the latest versions on to your machine.

The Github version is old, and should be deprecated - I'll do this now, thanks.

Cheers,

Steve

Link to comment
Share on other sites

@Giuseppe Iannacone No worries. Sorry, I didn't realise that old Github repo was linked on the wiki, I'll get that updated too. We moved the PowerShell modules over to the PowerShell Gallery a good while ago, so that we had a single module source for both Windows and Azure PowerShell, rather than maintaining two codebases.

If you visit the module pages linked above, and expand Package Details, you will get a list of the cmdlets exported by the module:

image.png

And if you expand FileList and click on the psm1 file, this will show you the cmdlet sourcecode, with documentation contained within for each of the exported cmdlets. See the below for Add-HB-Param:

image.png

Cheers,

Steve

 

 

Link to comment
Share on other sites

@Giuseppe Iannacone,

Is the substate value not being updated in the record, if you were to check it in Database Direct? What about if you populate the h_substate_name field too? I'm not sure how the interface works in this app, so maybe @ArmandoDM would be best placed to assist, as this isn't an issue with the module...

Thanks,

Steve

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...