I am working on a script in which I need to get the current clustername for a given VM. Is there a one-liner type function that would perform the following idea:
$clustername = Get-Cluster($VMname)
Obviously that function isn't valid, but that is what I am trying to accomplish. Thanks!
Select-Object is a cmdlet. 😉
If efficiency is a concern (probably not in this case), you can remove the unnecessary pipe to Select-Object:
$clustername = (Get-Cluster -VM $VMname).Name