centos - How to identify with Powershell if Hyper-v VM has reached login screen -


i have created centos 7 minimal vm running under hyper-v. have installed transmission , set start service on boot using systemctl enable transmission-daemon.service

i want write powershell script start server, wait until active , open url see transmission web interface.

i have used get-vmintegrationservice returns value of ok heartbeat partway through boot. i've therefore had resort start-sleep wait 15 seconds when script opens browser doesn't timeout.

is there way establish login screen has been reached? or more elegant way of doing this?

this current startup powershell script:

$vmtostart="centos_7_minimal" $url="http://"+$vmtostart+":9091/"    if ((get-vmintegrationservice $vmtostart | ?{$_.name -eq "heartbeat"}).primarystatusdescription -ne "ok")  {     write-host "starting transmission server..." -foregroundcolor "blue"     start-vm $vmtostart     {start-sleep -milliseconds 100}          until ((get-vmintegrationservice $vmtostart | ?{$_.name -eq "heartbeat"}).primarystatusdescription -eq "ok")      write-host "transmission server started." -foregroundcolor "yellow"     write-host "starting transmission service..." -foregroundcolor "blue"     start-sleep -seconds 15 } start-process $url 

elegant not, check if site need vm available polling it. .net webclient quite straightforward use. see example below.

$webclient = new-object system.net.webclient $url = "http://www.stackoverflow.com"  {      start-sleep -seconds 1       try { $content = $webclient.downloadstring($url) }      catch { write-host "page not yet retrieved . . ."} } while ( $content -eq $null) 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -