Hey all,
I'm trying to create a [large for me] script that will basically swap VMs around (when a production VM 'blows up' and a full VM restore happens, I want to run a script that grabs certain information from the production server and the restored copy of the server and swaps them out basically. It's about 15 steps to do what we do manually in the vCenter GUI, but getting stuck at the beginning (and feeling silly).
Right now, I have the script looking at the production server and grabbing the information (Folder it's in, datastore it's on, VLAN it's on) and trying to output that information to verify that I have it right before proceeding with the script.
This part of the code looks like:
$vmnn = get-vm $srvr | Get-NetworkAdapter | Select-Object NetworkName
$vmds = get-vm $srvr | get-datastore | select Name
$vmfldr = get-vm $srvr | select Folder
Write-Host "Production server is in folder $vmfldr and on datastore $vmds and on VLAN $vmnn"
When I run it, it shows:
Production server is in folder @{Folder=ABC} and on datastore @{Name=ClonesDatastore} and on VLAN @{NetworkName=733-ABC}
I just want the values to be shown and I'm assuming that it's showing it in an expression instead of string value? If I don't use the Write-Host cmdlt and just do:
$vmfldr
For instance, it'll show:
Folder
------
ABC
I'd like it to look like this:
Production server is in folder ABC and on datastore ClonesDatastore and on VLAN 733-ABC
Any help would be appreciated!