Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 251313

Unable to get the ServiceTag Info

$
0
0

Hi Admins,

 

After searching the community I got some script on Service Tag and I modified the script slightly. However I am not getting the expected results. Could you please check and update the below code?

 

My Script:

$user = 'userid@company.net'

$pswd = 'password'

 

 

Import-Csv -Path .\Host.csv -UseCulture -PipelineVariable row |

ForEach-Object -Process {

   try

   {

   (Get-VMHost $row.host | Get-View).Summary.Hardware.OtherIdentifyingInfo[0].IdentifierValue

   $result = ""

   }

   catch

   {

   $result = "null"

   }

   $row | Add-Member -MemberType NoteProperty -Name 'result' -Value $result -PassThru

  # $row | Add-Member -MemberType NoteProperty -Name 'vCenter' -Value $@{N ="vCenter";E={([uri]$_.ExtensionData.Client.ServiceUrl).Host}} -PassThru

 

} | Export-Csv -Path .\servicetags-result.csv -NoTypeInformation

 

Expected Output:

servicetags                                        result                               vCenter

hostname1.site1.domain.net              DellServiceTag1              vCenter1.site1.domain.net

hostname2.site1.domain.net              DellServiceTag2              vCenter1.site1.domain.net

hostname1.site2.domain.net              DellServiceTag3              vCenter2.site2.domain.net

hostname1.site2.domain.net              DellServiceTag4             vCenter2.site2.domain.net

hostname1.site3.domain.net              DellServiceTag5             vCenter3.site3.domain.net

 

But getting the output as below:

Length

7

 

7

 

7

 

7

 

 

 

Message was edited by: User. Updated the code, code output & attached file.


Viewing all articles
Browse latest Browse all 251313

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>