I'm trying to build a tool that creates a bootable usb and assign a free drive letter I found here a useful script and did some modification to it
$freeletter = get-wmiobject win32_logicaldisk | select -expand DeviceID -Last 1 | % { [char]([int][char]$_[0] + 1) + $_[1] }
$splitted = $freeletter -split ":"
[char]$splitted
now I have the free drive letter stored in "$splitted" variable but when I run the following command
New-Partition -DiskNumber $disknumber -UseMaximumSize -IsActive:$true -DriveLetter $splitted
I receive the following error:
New-Partition : Cannot process argument transformation on parameter 'DriveLetter'. Cannot convert the "System.String[]" value of type "System.String[]" to type
"System.Char".
any suggestion please