How to remove mapped network drive with Powershell?











up vote
0
down vote

favorite












I am trying to create and remove a new mapped network drive using PowerShell.



It creates the mapped drive, however I can't seem to remove the mapped drive. The error message I receive is:




Dir : Cannot find path 'C:Windowssystem32P' because it does not exist.




New-PSDrive -Name "P" -Root "\VM-Blue-RobinTesting" -Persist -PSProvider "FileSystem" 
#Get-PSDrive P | Remove-PSDrive
#Remove-PSDrive -Name P -Force
#Remove-PSDrive P, Z


All Google and Stack Overflow has suggested to me thus far is using the commands that I have previously commented out. I am unsure of what I am doing wrong but had a feeling it could be done to the location of my files perhaps?



All help would be greatly appreciated!










share|improve this question
























  • Are you getting any specific error messages using Remove-PSDrive?
    – TobyU
    20 hours ago










  • @TobyU it ays Dir : Cannot find path 'C:Windowssystem32P' because it does not exist. However when I run Dir P, or Get-PSDrive. I can see the drive does exist
    – Edward Muldrew
    20 hours ago






  • 1




    If you intend to remove the drive soon, why do you add the -Persist parameter and I'D then add a -Sope to minimize possible other processes stepping in.
    – LotPings
    19 hours ago






  • 1




    The error is because your running dir P instead of dir P: You need the : to signify a drive not a folder.
    – James C.
    19 hours ago

















up vote
0
down vote

favorite












I am trying to create and remove a new mapped network drive using PowerShell.



It creates the mapped drive, however I can't seem to remove the mapped drive. The error message I receive is:




Dir : Cannot find path 'C:Windowssystem32P' because it does not exist.




New-PSDrive -Name "P" -Root "\VM-Blue-RobinTesting" -Persist -PSProvider "FileSystem" 
#Get-PSDrive P | Remove-PSDrive
#Remove-PSDrive -Name P -Force
#Remove-PSDrive P, Z


All Google and Stack Overflow has suggested to me thus far is using the commands that I have previously commented out. I am unsure of what I am doing wrong but had a feeling it could be done to the location of my files perhaps?



All help would be greatly appreciated!










share|improve this question
























  • Are you getting any specific error messages using Remove-PSDrive?
    – TobyU
    20 hours ago










  • @TobyU it ays Dir : Cannot find path 'C:Windowssystem32P' because it does not exist. However when I run Dir P, or Get-PSDrive. I can see the drive does exist
    – Edward Muldrew
    20 hours ago






  • 1




    If you intend to remove the drive soon, why do you add the -Persist parameter and I'D then add a -Sope to minimize possible other processes stepping in.
    – LotPings
    19 hours ago






  • 1




    The error is because your running dir P instead of dir P: You need the : to signify a drive not a folder.
    – James C.
    19 hours ago















up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am trying to create and remove a new mapped network drive using PowerShell.



It creates the mapped drive, however I can't seem to remove the mapped drive. The error message I receive is:




Dir : Cannot find path 'C:Windowssystem32P' because it does not exist.




New-PSDrive -Name "P" -Root "\VM-Blue-RobinTesting" -Persist -PSProvider "FileSystem" 
#Get-PSDrive P | Remove-PSDrive
#Remove-PSDrive -Name P -Force
#Remove-PSDrive P, Z


All Google and Stack Overflow has suggested to me thus far is using the commands that I have previously commented out. I am unsure of what I am doing wrong but had a feeling it could be done to the location of my files perhaps?



All help would be greatly appreciated!










share|improve this question















I am trying to create and remove a new mapped network drive using PowerShell.



It creates the mapped drive, however I can't seem to remove the mapped drive. The error message I receive is:




Dir : Cannot find path 'C:Windowssystem32P' because it does not exist.




New-PSDrive -Name "P" -Root "\VM-Blue-RobinTesting" -Persist -PSProvider "FileSystem" 
#Get-PSDrive P | Remove-PSDrive
#Remove-PSDrive -Name P -Force
#Remove-PSDrive P, Z


All Google and Stack Overflow has suggested to me thus far is using the commands that I have previously commented out. I am unsure of what I am doing wrong but had a feeling it could be done to the location of my files perhaps?



All help would be greatly appreciated!







powershell






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 19 hours ago









James C.

7,95722030




7,95722030










asked 21 hours ago









Edward Muldrew

4611




4611












  • Are you getting any specific error messages using Remove-PSDrive?
    – TobyU
    20 hours ago










  • @TobyU it ays Dir : Cannot find path 'C:Windowssystem32P' because it does not exist. However when I run Dir P, or Get-PSDrive. I can see the drive does exist
    – Edward Muldrew
    20 hours ago






  • 1




    If you intend to remove the drive soon, why do you add the -Persist parameter and I'D then add a -Sope to minimize possible other processes stepping in.
    – LotPings
    19 hours ago






  • 1




    The error is because your running dir P instead of dir P: You need the : to signify a drive not a folder.
    – James C.
    19 hours ago




















  • Are you getting any specific error messages using Remove-PSDrive?
    – TobyU
    20 hours ago










  • @TobyU it ays Dir : Cannot find path 'C:Windowssystem32P' because it does not exist. However when I run Dir P, or Get-PSDrive. I can see the drive does exist
    – Edward Muldrew
    20 hours ago






  • 1




    If you intend to remove the drive soon, why do you add the -Persist parameter and I'D then add a -Sope to minimize possible other processes stepping in.
    – LotPings
    19 hours ago






  • 1




    The error is because your running dir P instead of dir P: You need the : to signify a drive not a folder.
    – James C.
    19 hours ago


















Are you getting any specific error messages using Remove-PSDrive?
– TobyU
20 hours ago




Are you getting any specific error messages using Remove-PSDrive?
– TobyU
20 hours ago












@TobyU it ays Dir : Cannot find path 'C:Windowssystem32P' because it does not exist. However when I run Dir P, or Get-PSDrive. I can see the drive does exist
– Edward Muldrew
20 hours ago




@TobyU it ays Dir : Cannot find path 'C:Windowssystem32P' because it does not exist. However when I run Dir P, or Get-PSDrive. I can see the drive does exist
– Edward Muldrew
20 hours ago




1




1




If you intend to remove the drive soon, why do you add the -Persist parameter and I'D then add a -Sope to minimize possible other processes stepping in.
– LotPings
19 hours ago




If you intend to remove the drive soon, why do you add the -Persist parameter and I'D then add a -Sope to minimize possible other processes stepping in.
– LotPings
19 hours ago




1




1




The error is because your running dir P instead of dir P: You need the : to signify a drive not a folder.
– James C.
19 hours ago






The error is because your running dir P instead of dir P: You need the : to signify a drive not a folder.
– James C.
19 hours ago














1 Answer
1






active

oldest

votes

















up vote
2
down vote













The error is because you're running dir P instead of dir P: You need the : to signify a drive not a folder.



dir (which in Powershell is a actually an alias for Get-ChildItem) can read multiple areas of the OS so you need to be more specific with what you tell it.



Examples:




  • File system: Get-ChildItem C:

  • Registry: Get-ChildItem HKCU:

  • Certificate Store: Get-ChildItem cert:


Whilst with Get/Remove-PSDrive commands you are specifically telling it you want a "FileSystem" drive so it knows that Name is a drive letter.





With regards to removing the drive, either of the two commands you've listed will work fine:



New-PSDrive -Name P -Root "\VM-Blue-RobinTesting" -Persist -PSProvider "FileSystem" 

Get-PSDrive P | Remove-PSDrive
Remove-PSDrive -Name P -Force





share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372049%2fhow-to-remove-mapped-network-drive-with-powershell%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    The error is because you're running dir P instead of dir P: You need the : to signify a drive not a folder.



    dir (which in Powershell is a actually an alias for Get-ChildItem) can read multiple areas of the OS so you need to be more specific with what you tell it.



    Examples:




    • File system: Get-ChildItem C:

    • Registry: Get-ChildItem HKCU:

    • Certificate Store: Get-ChildItem cert:


    Whilst with Get/Remove-PSDrive commands you are specifically telling it you want a "FileSystem" drive so it knows that Name is a drive letter.





    With regards to removing the drive, either of the two commands you've listed will work fine:



    New-PSDrive -Name P -Root "\VM-Blue-RobinTesting" -Persist -PSProvider "FileSystem" 

    Get-PSDrive P | Remove-PSDrive
    Remove-PSDrive -Name P -Force





    share|improve this answer

























      up vote
      2
      down vote













      The error is because you're running dir P instead of dir P: You need the : to signify a drive not a folder.



      dir (which in Powershell is a actually an alias for Get-ChildItem) can read multiple areas of the OS so you need to be more specific with what you tell it.



      Examples:




      • File system: Get-ChildItem C:

      • Registry: Get-ChildItem HKCU:

      • Certificate Store: Get-ChildItem cert:


      Whilst with Get/Remove-PSDrive commands you are specifically telling it you want a "FileSystem" drive so it knows that Name is a drive letter.





      With regards to removing the drive, either of the two commands you've listed will work fine:



      New-PSDrive -Name P -Root "\VM-Blue-RobinTesting" -Persist -PSProvider "FileSystem" 

      Get-PSDrive P | Remove-PSDrive
      Remove-PSDrive -Name P -Force





      share|improve this answer























        up vote
        2
        down vote










        up vote
        2
        down vote









        The error is because you're running dir P instead of dir P: You need the : to signify a drive not a folder.



        dir (which in Powershell is a actually an alias for Get-ChildItem) can read multiple areas of the OS so you need to be more specific with what you tell it.



        Examples:




        • File system: Get-ChildItem C:

        • Registry: Get-ChildItem HKCU:

        • Certificate Store: Get-ChildItem cert:


        Whilst with Get/Remove-PSDrive commands you are specifically telling it you want a "FileSystem" drive so it knows that Name is a drive letter.





        With regards to removing the drive, either of the two commands you've listed will work fine:



        New-PSDrive -Name P -Root "\VM-Blue-RobinTesting" -Persist -PSProvider "FileSystem" 

        Get-PSDrive P | Remove-PSDrive
        Remove-PSDrive -Name P -Force





        share|improve this answer












        The error is because you're running dir P instead of dir P: You need the : to signify a drive not a folder.



        dir (which in Powershell is a actually an alias for Get-ChildItem) can read multiple areas of the OS so you need to be more specific with what you tell it.



        Examples:




        • File system: Get-ChildItem C:

        • Registry: Get-ChildItem HKCU:

        • Certificate Store: Get-ChildItem cert:


        Whilst with Get/Remove-PSDrive commands you are specifically telling it you want a "FileSystem" drive so it knows that Name is a drive letter.





        With regards to removing the drive, either of the two commands you've listed will work fine:



        New-PSDrive -Name P -Root "\VM-Blue-RobinTesting" -Persist -PSProvider "FileSystem" 

        Get-PSDrive P | Remove-PSDrive
        Remove-PSDrive -Name P -Force






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 19 hours ago









        James C.

        7,95722030




        7,95722030






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372049%2fhow-to-remove-mapped-network-drive-with-powershell%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

            Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

            A Topological Invariant for $pi_3(U(n))$