Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Here is my codes:

$map = new-Object -com wscript.Network
$map.mapNetworkDrive("v:","\\sharespace\testbuilds\test1")
$fso = new-Object -com Scripting.FileSystemObject
$do = $fso.getdrive("v")
$do.AvailableSpace
$do.TotalSize

I was mean to some check free share spaces. When I ran these codes at the first time I got a correct size data. BUt when I change the path on the 2nd line, it give me an error alarm:

 Exception calling "MapNetworkDrive" with "2" argument(s): "The local device name is already in use."
 At D:\test2fornetworkspace.ps1:5 char:21
 + $map.mapNetworkDrive <<<< ("v:","\\sharespace\testbuilds\test1")
 + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
 + FullyQualifiedErrorId : ComMethodTargetInvocation

And then, the result came out and alway same to the first running result... Of couse different sharespace with the different free size. So this is totally wrong...

Why this happened? Please give me some help..many thanks....

share|improve this question

1 Answer 1

up vote 1 down vote accepted

It is telling you V: is already mapped. You need to drop that mapping to reuse the drive letter V.

You should do this before re-mapping another drive to V:

$map.removenetworkdrive("v:")

share|improve this answer
    
Thank you very much:) –  pansal Jul 8 '11 at 5:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.