query different free share spaces by powershell, but every time got the same result
Here is my codes:
$map = new-Object -com wscript.Network
$map.mapNetworkDrive("v:","\sharespacetestbuildstest1")
$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:","\sharespacetestbuildstest1")
+ 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….
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:")
Check more discussion of this question.
Related posts:
- Failed to check share space via recorded path form sql database by powershell
- Why can’t I get the size of network shared folder? by powershell
- Doest Get-PSDrive can map network space?
- Where do you share or find useful powershell, bash, batch, vbs, scripts?
- SWAP CRITICAL – 100% free (0 MB out of 0 MB)?
Leave a comment
Recent Posts
Tags
active-directory
amazon-ec2
apache
apache2
backup
bash
centos
cisco
command-line
debian
dns
email
exchange
firewall
iis
iis7
iptables
linux
macosx
monitoring
mysql
networking
nginx
performance
permissions
php
postfix
raid
security
sql-server
sql-server-2005
sql-server-2008
ssh
ssl
ubuntu
unix
virtualization
vpn
webserver
windows
windows-7
windows-server-2003
windows-server-2008
windows-server-2008-r2
windows-xp





