Automation

 View Only
Expand all | Collapse all

Find VMs without NSX Security Tags

pamiller21

pamiller21Feb 04, 2020 08:57 PM

LucD

LucDFeb 05, 2020 05:13 PM

  • 1.  Find VMs without NSX Security Tags

    Posted Feb 03, 2020 08:35 PM

    Is there a way to make a report that shows any vms without a security tag attached, print it to html, and add a total at the bottom.  Is this doable or is something needed to pull this data from NSX?



  • 2.  RE: Find VMs without NSX Security Tags

    Posted Feb 03, 2020 08:51 PM

    To start you could verify if those tags are visible with the regular tag cmdlets.

    Do they show when you do a Get-TagAssignment?



  • 3.  RE: Find VMs without NSX Security Tags

    Posted Feb 04, 2020 07:45 PM

    It does not seem to show up with those commands.



  • 4.  RE: Find VMs without NSX Security Tags

    Posted Feb 04, 2020 07:51 PM

    Then you will have to use the PowerNSX module I guess.

    Something like this

    Get-VM | where{(Get-NsxSecuritytagassignment) -eq $null}



  • 5.  RE: Find VMs without NSX Security Tags

    Posted Feb 04, 2020 08:57 PM

    Sorry it just ask for a security tag:



  • 6.  RE: Find VMs without NSX Security Tags

    Posted Feb 04, 2020 09:04 PM

    Then try the one I provided in Re: Security Tags in NSX



  • 7.  RE: Find VMs without NSX Security Tags

    Posted Feb 05, 2020 04:46 PM

    I am struggling hard on this, no idea why, but this is what I see when I just try to connect to my NSX Manager:



  • 8.  RE: Find VMs without NSX Security Tags

    Posted Feb 05, 2020 05:01 PM

    I assume you already saw Kyle's post Getting Started with the PowerCLI Module for VMware NSX-T ?

    The only difference I see is the credentials, but the error seems to come earlier.


    Does adding the -Verbose switch give any more information?



  • 9.  RE: Find VMs without NSX Security Tags

    Posted Feb 05, 2020 05:13 PM

    Could this be a DNS issue?



  • 10.  RE: Find VMs without NSX Security Tags

    Posted Feb 05, 2020 07:30 PM

    No DNS name is used, just IP.  Wanted to rule that out to start.  I used the verbose tag and didn't show anything new.



  • 11.  RE: Find VMs without NSX Security Tags

    Posted Feb 05, 2020 07:45 PM

    Did you check the TLS version(s) your PowerShell session can use?

    [Net.ServicePointManager]::SecurityProtocol

    If TLS12 is not in there, run the following before trying the connection

    [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12,

        [System.Net.SecurityProtocolType]::Tls11,

        [System.Net.SecurityProtocolType]::Tls



  • 12.  RE: Find VMs without NSX Security Tags

    Posted Feb 05, 2020 08:04 PM

    Sorry shows this:

    PS C:\Windows\system32> [Net.ServicePointManager]::SecurityProtocol

    Tls12

    PS C:\Windows\system32>



  • 13.  RE: Find VMs without NSX Security Tags

    Posted Feb 05, 2020 08:08 PM

    That seems to be ok.

    I'm at my wit's end, for now, I'm afraid.



  • 14.  RE: Find VMs without NSX Security Tags

    Posted Feb 05, 2020 09:24 PM

    Please forgive me, I am losing my mind slowly and simply typed the IP wrong.  Again VERY SORRY, but there is a new error:



  • 15.  RE: Find VMs without NSX Security Tags

    Posted Feb 05, 2020 09:32 PM

    Are you getting the same error when you provide all the values on the cmdlet, instead of being prompted for them?



  • 16.  RE: Find VMs without NSX Security Tags

    Posted Feb 05, 2020 09:41 PM

    Yes both ways



  • 17.  RE: Find VMs without NSX Security Tags

    Posted Feb 05, 2020 09:46 PM

    To eliminate any 'dirty bits', did you stop/start your PowerShell session before trying again?



  • 18.  RE: Find VMs without NSX Security Tags

    Posted Feb 07, 2020 03:10 PM

    Ya I did that, no change



  • 19.  RE: Find VMs without NSX Security Tags

    Posted Feb 07, 2020 03:40 PM

    I think you might want to open an SR for this.



  • 20.  RE: Find VMs without NSX Security Tags

    Posted Feb 07, 2020 04:31 PM

    Sorry where can I put a SR in for this product?



  • 21.  RE: Find VMs without NSX Security Tags

    Posted Feb 07, 2020 04:35 PM

    You can open a regular SR (you don't need a Developer Support contract).

    See PowerCLI Support Breakdown
    Refer to that post when GSS claims you do need Developer Support.



  • 22.  RE: Find VMs without NSX Security Tags

    Posted Feb 11, 2020 09:09 PM

    Entered the SR under NSX and support said they can check if the script is hitting it but that is all. No further support given.



  • 23.  RE: Find VMs without NSX Security Tags

    Posted Feb 11, 2020 09:11 PM

    You should also be able to open a SR under PowerCLI afaik



  • 24.  RE: Find VMs without NSX Security Tags

    Posted Feb 12, 2020 07:28 AM

    After messing around for a few hours I think I got it.  I needed to connect to a vcenter first then it worked.  Now I am working on finding VMs without any security group assigned.  Sorry for the switching of gears, but I think the group might be easier and get me same content.  But missing something as this just named all my VMs.

    get-vm | select name | ?{ ( Get-NsxSecurityGroup $_) -eq $null}



  • 25.  RE: Find VMs without NSX Security Tags
    Best Answer

    Posted Feb 12, 2020 07:58 AM

    Great.

    Can you try like this

    Get-VM |

    where {(Get-NsxSecuritytagassignment -VirtualMachine $_) -eq $null}

    select name



  • 26.  RE: Find VMs without NSX Security Tags

    Posted Feb 12, 2020 07:09 PM

    This is perfect, thank you so much!