PowerFGT icon indicating copy to clipboard operation
PowerFGT copied to clipboard

Get-FGTFirewallAddressGroup return showing only 4x member entries...

Open poundy opened this issue 4 years ago • 6 comments

I totally know how to get access to the .Member property, and suspect that this is just a PS behaviour that can't be overridden, but it'd be nice if it could. When you use Get-FGTFirewallAddressMember, the output shows up to 4 members and then an ellipsis of members... Is there any way to influence that to report them all ?

uuid          : 37231bb8-ebc3-51e9-dd1f-a50c2fa0b8cf
member        : {@{q_origin_key=H_10.1.0.1; name=H_10.1.0.1}, 
                @{q_origin_key=H_10.1.0.2; name=H_10.1.0.2}, 
                @{q_origin_key=H_10.1.0.3; name=H_10.1.0.3}, 
                @{q_origin_key=H_10.1.0.4; name=H_10.1.0.4}...}
comment       : 

poundy avatar Mar 03 '20 10:03 poundy

Good question but i don't known... (i think it is a settings of powershelll)...

alagoutte avatar Mar 03 '20 12:03 alagoutte

You can override the output of function. But you need to custom the type of object that it returns.

$Object = [PSCustomObject]@{}
$Object.PStypeNames.Clear()
$Object.PStypeNames.Add(MyType)

You can see the new type with Get-Member :

$Object | Get-Member


   TypeName: MyType

Name        MemberType Definition
----        ---------- ----------
Equals      Method     bool Equals(System.Object obj)
GetHashCode Method     int GetHashCode()
GetType     Method     type GetType()
ToString    Method     string ToString()

After that, you need to add View in .format.ps1xml. Look at about_format.ps1xml

NicolasBn avatar Mar 03 '20 17:03 NicolasBn

Thanks @NicolasBn !

alagoutte avatar Mar 03 '20 19:03 alagoutte

can be close ?

alagoutte avatar Mar 10 '20 09:03 alagoutte

This one I think I would like to put as a future improvement - so that the return from the get-* was a little clearer. Some of my use-cases are very clearly inside a script and the return isn't that important as I'll hide the output and manage it myself, but I think the interactive use-case could definitely benefit from that improvement.

I have no idea how best to manage this kind of issue/item... but have no qualms if you just want it closed.

I haven't quite wrapped my mind about how I'd go about addressing this as per the above, but haven't looked deep enough (I'm sidetracking myself wanting to see if the API will handle Add-FGTFirewallPolicy with a PolicyID - but more on that later ;) )

poundy avatar Mar 10 '20 10:03 poundy

Ok, i kept for enhance

I will look a day for try @NicolasBn solution

but actually, I'm only display the direct output of API

alagoutte avatar Mar 10 '20 13:03 alagoutte