Please feel free to provide feedback or file bugs here.

very inconsistent drive letter usage

Hi there

in this case I have to remove and reinstall an OS while booting from usb stick. But this is only one example - it´s not the first time im seeing this behaviour.

if (Test-path c:) {Get-Volume -DriveLetter c | Get-Partition | Remove-PartitionAccessPath -AccessPath c:\}

In this line the term C is used three times

First time as c: (here would be c:\ also possible)
Second time as c (neither c: nor c:\ is working here)
Third time as c:\ (neither c nor c: is working here)

I´m working with variables - this means I have to create 3 Variables to obey all this rules.

My suggestion - decide for one notation and use this consistently! everywhere!

3 votes
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)

    We’ll send you updates on this idea

    LoggSar shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    3 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • James Lear commented  ·   ·  Flag as inappropriate

        I think JB Lewis has got the right answer.

        There is a big difference between drive paths and volume names.

      • JB Lewis commented  ·   ·  Flag as inappropriate

        $DriveLetter = "C"
        if (Test-Path "$DriveLetter`:"){Get-Volume -DriveLetter $DriveLetter | Get-Partition | Remove-PartitionAccessPath -AccessPath "$DriveLetter`:\"}

      Feedback and Knowledge Base