- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Mark,
To loop through all the the host one by one, you can try:
foreach ($VMHost in Get-VMHost) { Scan-Inventory -Entity $VMHost }
Robert