VMware Cloud Community
mark_chuman
Hot Shot
Hot Shot

Scan-Inventory Question

My goal is to scan each ESX server in a vCenter server one by one with a powershell script using the Scan-Inventory cmdlet. I was thinking I could do something like this "Scan-Inventory -Entity " where it would Scan the inventory, but only scan ESX servers and nothing else. Looks like "-Entity" is just the name of an entity. Anyway, trying to accomplish this with the below, but the expected output is not good.

C:\Program Files\VMware\Infrastructure\VIToolkitForWindows> get-vmhost | select -ExpandP

roperty Name | ForEach-Object {Scan-Inventory}

cmdlet Scan-Inventory at command pipeline position 1

Supply values for the following parameters:

Entity[0]:

Not sure if scan-inventory doesn't accept pipe info? Anyone know why this keeps popping up?

**cmdlet Scan-Inventory at command pipeline position 1**

**Supply values for the following parameters:**

**Entity[0]:**

Thanks

0 Kudos
5 Replies
mark_chuman
Hot Shot
Hot Shot

this may add

Scan-Inventory : Cannot process argument transformation on parameter 'Entity'. Strings as pipeline input a

re not supported.

At line:1 char:58

+ get-vmhost | select -ExpandProperty Name | Scan-Inventory <<<<

+ CategoryInfo : InvalidData: (esxname.domain.com:PSObject) , Parameter

Bindin...mationException

+ FullyQualifiedErrorId : ParameterArgumentTransformationError,VMware.VumAutomation.Commands.ScanInve

ntory

when i run this:

C:\Program Files\VMware\Infrastructure\VIToolkitForWindows> get-vmhost | select -ExpandP

roperty Name | Scan-Inventory

*I get the above error for each ESX host name.

0 Kudos
mark_chuman
Hot Shot
Hot Shot

This worked if others are interested:

get-vmhost | ForEach-Object {Scan-Inventory -Entity $_.name}

It loops through and scans all ESX servers in the server you are connected to. Scans one by one and shows percentage in the powershell console.

0 Kudos
bbambalova
VMware Employee
VMware Employee

You can pipe to the Scan-Inventory the objects returned by Get-VMHost cmdlet.

Get-VMHost | Scan-Inventory

Is there any specific reason, because you want to pass the entity's name to the Scan-Inventory?

mark_chuman
Hot Shot
Hot Shot

Yeah, that works - Thanks. It does kick off all the scans at the same time. We have a huge environment 700+, so that would kill my vCenter servers. Anyway you could take that and make it loop through one by one?

Thanks for the reply, appreciate it.

0 Kudos
RvdNieuwendijk
Leadership
Leadership

Mark,

To loop through all the the host one by one, you can try:

foreach ($VMHost in Get-VMHost) { Scan-Inventory -Entity $VMHost }

Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos