- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
get the name of Vnic from windows to pwercli
hello
I need to get the name of Vnic (normally named :ethernetx) from windows to pwercli
can any one help me please
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try something like this.
You will have to provide credentials for an account that can logon to the Windows OS.
$user = 'domain\user'
$pswd = 'VMware1!'
$cred = New-Object -TypeName PSCredential -ArgumentList $user,(ConvertTo-SecureString -String $pswd -AsPlainText -Force)
$code = @'
Get-NetAdapter | Select Name,@{N='MacAddress';E={$_.MacAddress.Replace('-',':')}} | ConvertTo-Csv
'@
Get-VM -PipelineVariable vm |
ForEach-Object -Process {
$result = Invoke-VMScript -ScriptText $code -VM $vm -GuestCredential $cred
Get-NetworkAdapter -VM $vm -PipelineVariable vnic |
Select @{N='VM';E={$vm.Name}},
Name,
@{N='OSName';E={$result.ScriptOutput | ConvertFrom-Csv | where{$_.MacAddress -eq $vnic.MacAddress} | Select -expandProperty Name}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you LucD
I'll test this