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!
powershell
add a comment |
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!
powershell
Are you getting any specific error messages usingRemove-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 runningdir P
instead ofdir P:
You need the:
to signify a drive not a folder.
– James C.
19 hours ago
add a comment |
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!
powershell
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
powershell
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 usingRemove-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 runningdir P
instead ofdir P:
You need the:
to signify a drive not a folder.
– James C.
19 hours ago
add a comment |
Are you getting any specific error messages usingRemove-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 runningdir P
instead ofdir 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
add a comment |
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
add a comment |
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
add a comment |
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
add a comment |
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
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
answered 19 hours ago
James C.
7,95722030
7,95722030
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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 ofdir P:
You need the:
to signify a drive not a folder.– James C.
19 hours ago