- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
import-csv
Hi Luc,
i am getting very weird error .following code works fine till orange
however when i m trying to get vmhost to do further activities it throws error .
esxi1.localhost.com
get-vmhost : 28/10/2020 14:45:32 Get-VMHost VMHost with name
'esxi1.localhost.com ' was not found using the specified filter(s).
At line:6 char:1
+ get-vmhost -Name $v
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (:) [Get-VMHost], VimException
+ FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimA
utomation.ViCore.Cmdlets.Commands.GetVMHost
$esxis=import-csv "C:\Users\jvmishra\Desktop\fileroot.csv"
foreach($e in $esxis)
{
$v=$e.esxiname
$v
get-vmhost -Name $v
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there a space character after .com in your csv file? There is in the error you posted:
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There seems to be an extra space at the end of 'esxi1.localhost.com '
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
not sure how it appeared .its fine if i m printing $v
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I suspect it already is there in the CSV
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i dont see any space in the file .i tested one of them with get-vmhost command and it worked fine ..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Check with the Length property if the extra blank is in there.
$v.Length
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
its not there as i m able to use get-vmhost $v when i run individually .
moreover the space seems to come at the end of the fqdn dont know how it happened .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
$v.length issame as sum of individual charecters.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would need to see your CSV and script file (as attachments) to further analyse.
I tested this, and indeed an extra space at the end of the ESXi node name produces the same error.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i put comma after each esxi name .it is working now .however i did this multiple times in past and for a single column i did not use coma and it used to work...
esxiname
esxi1.script-infra.local,
esxi2.script-infra.local,
esxi3.script--infra.local,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm still pretty sure there was some sort of whitespace (blank, tab ...) at the end of one or more lines in your CSV.
By placing the comma at the end, you have a visual confirmation that there is no trailing blank on a row.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
well its working now with comma ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm pretty sure you fixed the issue in the CSV by adding the useless comma.
As a test, remove the comma and test again.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
without comma i cant get the proper output .i m unable to send the .csv file due to security reasons.