powershell - Not showing Table of Objects until after Pause -


have tried searching interwebs, majority of results show when people accidentally hit key when powershell console active.

the issue i'm facing store hyper-v object in variable , call variable.

the following snippet script.

$listdisks = get-vmharddiskdrive -vmname $vmname -controllertype scsi  "the following table show disks have been attached vm!" | write-host  $listdisks pause 

so when script executes runs , shows output it's supposed to. issue occurs when hit pause portion of script. get-vmharddiskdrive output doesn't appear until after hit "press enter continue..."

output:

the following table show disks have been attached vm!  press enter continue...:  vmname  controllertype controllernumber controllerlocation disknumber path                                 ------  -------------- ---------------- ------------------ ---------- ----                                 some-vm scsi           0                0                  15         disk 15 1.00 gb bus 0 lun 0 target 0 some-vm scsi           1                0                  28         disk 28 1.00 gb bus 0 lun 0 target 0 some-vm scsi           2                0                  30         disk 30 1.00 gb bus 0 lun 0 target 0 some-vm scsi           3                0                  16         disk 16 1.00 gb bus 0 lun 1 target 0 

it's not super big issue, i'm wondering why behavior occurs pause. if remove pause issue doesn't occur. why occurring?

**edit - forgot add utilizing powershell ise in windows server 2012 r2 hyper-v cmdlets. running script f5 , manually invoking script in ise console. issue not occur when utilizing regular powershell console.

this seems issue ise. can reproduce behavior describe if run code in ise, whereas works fine when run in regular powershell. ise , regular powershell known behaving different each other since they're different host environments.

you can work around issue enforcing host output, e.g. this:

$listdisks | out-host pause 

however, should avoid writing host unless it's presenting data user, because host output design , definition doesn't go of powershell's output streams , can't further processed.

if script intended being run in regular powershell console, wouldn't bother working around ise quirk.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -