PowerShell skips Get-Volume

Viewed 89

Can someone give me insight here? Powershell is skipping the Get-Volume command in the following lines:

## Warning message
Write-Host -ForegroundColor Red 'This application will delete all stored information on your disk. Please ensure this is what you want to do. Use with caution!'

## Get available disks
Get-Volume

## Select Disk
$diskDrive = Read-Host 'Which drive do you want to format/convert?'

I have tried to | it out to a variable and tried adding the -Verbose flag as well. Neither of which work. I feel sure it is something obvious but I'm missing it. Thanks in advance for the help.

1 Answers

Use the following:

Get-Volume | Out-Host

The issue is two of your commands interact directly with the PowerShell host. The Get-Volume command outputs to the pipeline (success stream most likely in this case). The host output does not use the pipeline so there's no perceived synchrony. The simplest answer in your case is to just output to the host for all of your commands.

Related