Have tried searching the interwebs, but majority of results only show when people accidentally hit a key when the PowerShell Console is active.
The issue I'm facing is that I store a Hyper-V object in a variable and call that variable.
The following snippet is from my script.
$ListDisks = Get-VMHardDiskDrive -VMName $VMName -ControllerType SCSI
"The following table will show which disks have been attached to the VM!" | Write-Host
$ListDisks
Pause
So when the script executes it runs and shows all the output like it's supposed to. Issue occurs when I hit the Pause portion of the script. The Get-VMHardDiskDrive
output doesn't appear until after I hit "Press Enter to continue..."
Output:
The following table will show which disks have been attached to the VM!
Press Enter to 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 a super big issue, I'm just wondering why this behavior only occurs with Pause. If I remove the Pause the issue doesn't occur. Why is this occurring?
**Edit - Forgot to add I was utilizing the PowerShell ISE in Windows Server 2012 R2 with Hyper-V Cmdlets. I was running the script with F5 and manually invoking the script in the ISE Console. Issue does not occur when utilizing a regular PowerShell Console.