0

I have a CD drive, without a drive letter, because I am trying to automatically rearrange Volumes. I want to use PowerShell a drive letter to the CD drive (here ISOIMAGE).

Picture of disk management

I removed it using the following:

$cdDrive = Get-WmiObject -Class Win32_volume -Filter 'DriveType=5' | Select-Object -First 1
$cdDrive | Set-WmiInstance -Arguments @{ DriveLetter = $null }

I assumed that something like this would therefore work:

$cdDrive | Set-WmiInstance -Arguments @{ DriveLetter = "F:\" }

To my confusion, PowerShell responded like this:

Set-WmiInstance : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.

I also tried:

Get-Volume | ? DriveType -eq "cd-rom" | Set-WmiInstance -Arguments @{ DriveLetter = "F:\" };
Get-Volume | ? DriveType -eq "cd-rom" | Set-WmiInstance -Arguments @{ DriveLetter = "F:\"; Label="bruh" };
Get-Volume | ? DriveType -eq "cd-rom" | Set-Partition -NewDriveLetter "F";
Omglolyes
  • 156
  • 11
  • Use `Set-Partition`: `Set-Partition -NewDriveLetter F`. – Abraham Zinala Nov 30 '22 at 15:38
  • As mentioned in the last line, I've also tried this. It results into: `Set-Partition : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.` – Omglolyes Nov 30 '22 at 15:41
  • Right, 'cause it won't be bound by the necessary parameters since the output of one command doesn't match the other. Either explicitly provide it the mandatory parameters of a set for `Set-Partition`, or pipe from `Get-Partition`. – Abraham Zinala Nov 30 '22 at 15:51

1 Answers1

0

It turns out $cdDrive has a method called AddMoundPoint, so $cdDrive.AddMountPoint("F:") worked.

Omglolyes
  • 156
  • 11