JMeterX
JMeterX

Reputation: 438

Get-Location with :\

I want to grab the current drive letter of the CD Drive and append :\ to it.

I was thinking something like

$test = (get-location).drive.name
$test2 = ":\"
$test = $test + $test2

Then, $test will equal p:\

This however doesn't seem very efficient, is there a better alternative?

Upvotes: 2

Views: 150

Answers (2)

Shay Levy
Shay Levy

Reputation: 126722

That's all true if you are already located in the cd drive. Here's an alternative way:

(Get-WmiObject Win32_CDRomDrive).Drive+'\'

Upvotes: 0

Nate Hekman
Nate Hekman

Reputation: 6657

How about

(get-location).drive.root

Upvotes: 3

Related Questions