VMware Cloud Community
miguelvelezwhit
Enthusiast
Enthusiast
Jump to solution

How to tell (via script) the difference between a Windows based vCenter or a vCSA

As some of you know, I've been working on scripting to mitigate both the PSOD and a frozen host which needs a reboot.  I've nearly got it all pulled together thanks to a lot of input from y'all, but as it turns out, dealing with the Network Core Dump Collector varies based on whether your vSphere environment is Windows based, or using the appliance. 

In order to get my head around all of it, I'm trying to create an 'if...then' branch in my code.  Where I'm stuck is how to code the test in PowerCLI to check whether a vCenter is Windows or if it is an appliance.  I thought I remembered seeing such a test a while back; particularly when the appliance was getting more attention, but I can't find it now.

Can anyone suggest a quick easy way to code for that kind of a test [check]?  I'm really anxious to get to this last part so that I can finish writing the code, test it and then share it on GitHub.  I've been trolling Git for so long, that I'm happy to hopefully have something worthy to contribute.

I'll keep you all posted.  Thanks in advance for all the help.

- Respectfully,

Migs

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

$global:DefaultVIServers |

Select Name,

  @{N='Type';E={if($_.ExtensionData.Content.About.OSType -match "^linux"){'vcsa'}else{'vCenter'}}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this

$global:DefaultVIServers |

Select Name,

  @{N='Type';E={if($_.ExtensionData.Content.About.OSType -match "^linux"){'vcsa'}else{'vCenter'}}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
miguelvelezwhit
Enthusiast
Enthusiast
Jump to solution

As always dude, you knocked that puppy right out of the park!!  It was amazing to run it across our whole vSphere environment, because I thought we had more appliances implemented.  It turns out that of all our vCenters across the country, less than 12% are VCSAs!!  I was shocked and that means I REALLY have work to do.  Time to set up these procedural branches.  At first I was thinking 'if...then....else'.  However, now I'm thinking about case structures; but even that seems like overkill.  As your coding of the test clearly shows, I've got one way of doing a process or another - I believe that they call that a 'binary choice' (I've only heard nearly every politician use that phrase during election season and now beyond.)

That being said, I'm really considering just coding the Windows part and the 12% I'll do manually.  The Linux side was always going to be difficult.  As  you may recall, the core dumping in VCSA is writing to a Linux partition which I was trying to copy to a CIFS share.  (Boy what a nightmare!!)  I still may have to do that, but now I don't  have to do it 16 or 17 times; just 3 or 4. *LOL*

Well, on to the next phase.  Many, MANY THANKS Jean-Luc (as always)               JLP_faceplant.jpg

- Migs

0 Kudos