vmware-archive / powernsx

PowerShell module that abstracts the VMware NSX-v API to a set of easily used PowerShell functions
173 stars 90 forks source link

DFW Change Notes #606

Closed Sk83r closed 4 years ago

Sk83r commented 4 years ago

Hi guys

Is there any way to change notes (comments) in DFW rules ?

$rule = get-nsxfirewallrule -ruleid xxx $rule.notes = "my comment"

How should I publish it now ?

Is there any PS script for bulk use per range of IDs or Section ? would be very handy

Thanks

alagoutte commented 4 years ago

Hi @Sk83r

if you using this :

$rule | Set-NsxFirewallrule 

the notes is updated ?

if you $rule have multiple rule inside, you can use also | Set-nsxFirewallRule

Sk83r commented 4 years ago

yes updated. Great!

How can I put into $rule array multiple rule IDs inside ?

I've tried Set-NsxFirewallRule with single id and -notes not a parameter in that command get-nsxfirewallrule -ruleid xxx| Set-NsxFirewallRule -notes "mycomment"

alagoutte commented 4 years ago

Yes, there is no yet "notes" parameter but it can be easy to add...

alagoutte commented 4 years ago

After a quick check, what relase of NSX-V do you are using ? because there is no notes field but description from NSX-V API Guide

Sk83r commented 4 years ago

Ver. 6.4. 3

Sk83r commented 4 years ago

But also if you can describe how to push multiple rule ids inside $rule array and how should I point each time to different rule id when I use $rule.notes

alagoutte commented 4 years ago

you need to store on $rule variable multiple rule

if you try

$rules = get-nsxfirewallrule -id XX
$rules += get-nsxfirewallrule -id YY
Sk83r commented 4 years ago
$rules = get-nsxfirewallrule -id

$rules = get-nsxfirewallrule -ruleid XX

$rules += get-nsxfirewallrule -ruleid YY Method invocation failed because [System.Xml.XmlElement] does not contain a method named 'op_Addition'. At line:1 char:1

Sk83r commented 4 years ago

yes updated. Great!

How can I put into $rule array multiple rule IDs inside ?

I've tried Set-NsxFirewallRule with single id and -notes not a parameter in that command get-nsxfirewallrule -ruleid xxx| Set-NsxFirewallRule -notes "mycomment"

Any alternative to this one which not supported ?

I want to get entire rules in section (TEST) and set for all rules under it with updated notes Something similar to this one below : Get-NsxFirewallSection TEST| Get-NsxFirewallRule | Set-NsxFirewallRule -notes "mycomment"

alagoutte commented 4 years ago

Need to add -notes parameter to Set-NsxFirewallRule

I will look later

Sk83r commented 4 years ago

Hey Alexis

Really need it please 🙏 I also noticed I can't set notes using var ($rule fo instance) if ruleid never had note before.

Means it's only possible to update existing notes in rules but not to set new ones.

alagoutte commented 4 years ago

Need to modified Set-NsxFirewallRule, i will try to look this week end

Sk83r commented 4 years ago

Have you had the chance to look into it?

alagoutte commented 4 years ago

Yes, i need to finish test...

alagoutte commented 4 years ago

@Sk83r do you have try ? (it is available on last release of powernsx)

Sk83r commented 4 years ago

Yes. Works like a charm! Exactly what I needed.

Appriciate your assistance, Alexis