Powershell提取网络共享并显示其大小 [英] Powershell to pull network share and display their Size
问题描述
所以我一直在编写一个脚本来拉取未隐藏的网络共享并显示它们的大小。但我得到一个错误,状态不包含名为'op_addition'的方法。该脚本应扫描所有非隐藏文件共享,并显示它们的
大小,以便它在运行它的机器上找到它。任何帮助是极大的赞赏。谢谢。
So i have been working on a script to pull network share that are not hidden and display their size. but i am getting a error that states does not contain a method named 'op_addition'. The script should scan for all non hidden file shares and disply their size for what ever it find on the machine it is run on. Any help is greatly appreciated. Thanks.
$startfolder = Get-WmiObject Win32_Share -Filter "not name like '%$'" | Select path
foreach($ startfolder.ToString中的$ folder){  
foreach($folder in $startfolder.ToString){
$ colItems =(Get-ChildItem $ folder -Recurse | Measure-Object -property length -sum)  
$colItems = (Get-ChildItem $folder -Recurse | Measure-Object -property length -sum)
IF($ colItems.Sum -ge 1073741824)  
IF($colItems.Sum -ge 1073741824)
{   
{
$ folder +" - " + " {0:N 2}" -f ($ colItems.sum / 1GB)+"千兆字节" 
$folder + " --" + " {0:n2}" -f ($colItems.sum / 1GB) + " GigaBytes"
}
ELSEIF($ colItems.sum -ge 1024)  
ELSEIF($colItems.sum -ge 1024)
{   
{
$ folder +" - " + " {0:N 2}" -f ($ colItems.sum / 1MB)+"兆字节"   
$folder + " --" + " {0:n2}" -f ($colItems.sum / 1MB) + " MegaBytes"
} 
ELSE   
ELSE
{    $ folder +" - " + " {0:N 2}" -f ($ colItems.sum / 1KB)+"千字节"   
{ $folder + " --" + " {0:n2}" -f ($colItems.sum / 1KB) + " KiloBytes"
}   
}
}
推荐答案
请尝试这样:
"
文件夹 - {0:n2} KiloBytes" -f(
folder -- {0:n2} KiloBytes" -f (
colItems.Sum / 1KB)
colItems.Sum / 1KB)
这篇关于Powershell提取网络共享并显示其大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!