Unable to suppress confirmation popups in Powershell for Format-volume and Remove-Partition
Hi
I use the script below to format a secondary drive, I am using the script below ( it basically checks for the required disk size and attempts to format it. If the disk exists already the partition is deleted and recreated ( sort of a reset function if my device is re configured )
Despite using the -Confirm:$false parameters I am still getting pop messages asking for confirmation. I am using Windows 10 IOT LTSC 2021. The process for setting the drive needs to be automated so confirmation boxes won’t work for me. Any advice will be greatly appreciated.
DD = get-disk |Where {$_.size -lt “35GB”}
$Part = $DD |Get-Partition
$Part |Remove-Partition -Confirm:$false
if ($DD.PartitionStyle -ne “GPT” -or $DD.PartitionStyle -ne “GPT” )
{Write-host “Disk not initialized.
Initializing” -for Yellow
$DD |Initialize-Disk -PartitionStyle GPT
}
if ($DD.PartitionStyle -eq “MBR”)
{
Write-Host “Partition style is MBR
Setting Partition Style to GPT” -Fore Yellow
$dd |Set-Disk -PartitionStyle GPT
}
$DD | New-Partition -UseMaximumSize -DriveLetter d
Format-Volume -DriveLetter d -FileSystem NTFS -NewFileSystemLabel “Backup” -Confirm:$false
MD d:Backup
Hi I use the script below to format a secondary drive, I am using the script below ( it basically checks for the required disk size and attempts to format it. If the disk exists already the partition is deleted and recreated ( sort of a reset function if my device is re configured ) Despite using the -Confirm:$false parameters I am still getting pop messages asking for confirmation. I am using Windows 10 IOT LTSC 2021. The process for setting the drive needs to be automated so confirmation boxes won’t work for me. Any advice will be greatly appreciated. DD = get-disk |Where {$_.size -lt “35GB”}$Part = $DD |Get-Partition$Part |Remove-Partition -Confirm:$falseif ($DD.PartitionStyle -ne “GPT” -or $DD.PartitionStyle -ne “GPT” ){Write-host “Disk not initialized.Initializing” -for Yellow$DD |Initialize-Disk -PartitionStyle GPT}if ($DD.PartitionStyle -eq “MBR”){Write-Host “Partition style is MBRSetting Partition Style to GPT” -Fore Yellow$dd |Set-Disk -PartitionStyle GPT}$DD | New-Partition -UseMaximumSize -DriveLetter dFormat-Volume -DriveLetter d -FileSystem NTFS -NewFileSystemLabel “Backup” -Confirm:$falseMD d:Backup Read More