I'd like to be able to display guest information in a multi-line message box. I've managed to get all the information I need, but I can't format it to come out on multiple lines. I tried vbNewLine in single-quotes, but it still just displays vbNewLine in the box.
Here's what I have so far (stitched together from other people's code I found):
Function Show-Inputbox {
Param([string]$message=$(Throw "You must enter a prompt message"),
[string]$title="Input",
[string]$default
)
[http://reflection.assembly|http://reflection.assembly]::loadwithpartialname("microsoft.visualbasic") | Out-Null
[http://microsoft.visualbasic.interaction|http://microsoft.visualbasic.interaction]::InputBox($message,$title,$default)
}
$strVM = Show-Inputbox -message "What is the name if the machine?" -title "Guest Info" -default machine_name
$vm = Get-VM -Name $strVM
if ($vm.PowerState -eq "PoweredOn") {
$event = Get-VIEvent -Entity $vm | where-object {$_.fullFormattedMessage -like "Task: Power on Virtual Machine"}
$VM.Name
$VM.PowerState
(Get-VMGuest -VM $VM).IPAddress[0]
$event[0].username
}
$strMessageText = $VM.Name+$VM.PowerState+(Get-VMGuest -VM $VM).IPAddress[0]+$event[0].username
$a = new-object -comobject wscript.shell
$b = $a.popup($strMessageText,0,"Guest Info",1)
Does anyone have any ideas on how to do this? Or alternative ways of displaying the info (in a non-scary way for users)?
Also, any hints as to how to optimise thise code would be apppreciated, it takes a while to run.