知识点:
1、获取路径中的文件夹:Get-ChildItem $startFolder  | Where-Object {$_.PSIsContainer -eq $True} | Sort-Object
2、获取文件夹的总大小Get-ChildItem $i.FullName -recurse | Measure-Object -property length -sum
3、 正则表达式:$DBname=  $fullname -replace "^.*data\\" 、
文档:\\localhost\D$\WENDY1\DBDATA\WENDY-MBX
匹配:WENDY-MBX
$startFolders="FOLDERPATH1","FOLDERPATH2"
foreach ($startFolder in $startFolders)
{
$colItems = (Get-ChildItem $startFolder | Where-Object {$_.PSIsContainer -eq $True} | Sort-Object)
foreach ($i in $colItems)
{
$subFolderItems = (Get-ChildItem $i.FullName -recurse | Measure-Object -property length -sum)
$fullname=$i.FullName
$SERVER=$fullname -replace "WENDY-MBX.*"
$DBname= $fullname -replace "^.*data\\"
$size=("{0:N2}" -f ($subFolderItems.sum / 1GB))
} }
$size=("{0:N2}" -f ($subFolderItems.sum / 1GB))         保留小数点后两位
$size=[math]::truncate($disk.size/1GB)                            截取小数点,保留整数
$date=get-date).TOSTRING("yyyy-dd-MM")
$servers= get-adcomputer -Filter {Name -Like "GAGA*" -or Name -Like "WENDY*" } -SearchScope Subtree -SearchBase "DC=WENDY,DC=CORP,DC=COM"
foreach ($server in $servers)
{
$servername=$server.name
$disks =Get-WmiObject Win32_LogicalDisk -ComputerName $servername -Filter "DriveType='3'"
forEach ($disk in $disks)
{
$DE=$disk.DeviceID
$size=[math]::truncate($disk.size/1GB)
$space=[math]::truncate($disk.freespace/1GB)
} }

Powershell Get File/Disk Size的更多相关文章

  1. Powershell split file

    #网上所得非原创 function split($inFile, $outPrefix, [Int32] $bufSize){ $stream = [System.IO.File]::OpenRead ...

  2. Powershell About File System

    File System Rights Get-Acl $sharepath | select -expand access | where { !$_.IsInherited -AND $_.file ...

  3. C# calculate disk size

    static void Main(string[] args) { string dir = @"C:\"; string[] dirs=Directory.GetDirector ...

  4. Linux下获取硬盘使用情况

    Linux下获取硬盘使用情况[总结] 1.前言 在嵌入式设备中,硬盘空间非常有限,在涉及到经常写日志的进程时候,需要考虑日志的大小和删除,不然很快就硬盘写满,导致日志程序崩溃.为了捕获硬盘写满的异常场 ...

  5. linux下获取硬盘使用情况[总结]

    1.前言 在嵌入式设备中,硬盘空间非常有限,在涉及到经常写日志的进程时候,需要考虑日志的大小和删除,不然很快就硬盘写满,导致日志程序崩溃.为了捕获硬盘写满的异常场景,我们需要在写日志过程中判断硬盘空间 ...

  6. [PowerShell Utils] Create a list of virtual machines based on configuration read from a CSV file in Hyper-V

    Hello everyone, this is the third post of the series. .   Background =============== In my solution, ...

  7. Windows Azure Storage (20) 使用Azure File实现共享文件夹

    <Windows Azure Platform 系列文章目录> Update 2016-4-14.在Azure VM配置FTP和IIS,请参考: http://blogs.iis.net/ ...

  8. The commands of Disk

    The commands of Disk fdisk( the disk size is less 2TB) fdisk - partition table manipulator for Linux ...

  9. Keil AGDI Header File

    #ifndef __AGDI__INCED___ #define __AGDI__INCED___ //---Revision History: --------------------------- ...

随机推荐

  1. elasticsearch mapping问题解决

    1.报错信息如下: [--16T00::,][WARN ][logstash.outputs.elasticsearch] Could not index event to Elasticsearch ...

  2. AHM ---301重定向

    使用amh.conf 或重新创建一个test.conf配置文件 .保存目录 /usr/local/nginx/conf/rewrite 例如跳到 www.shuaixingkeji.com if ($ ...

  3. Memcached管理与监控

    一个用PHP编写的可视化的MemCached管理系统 MemAdmin是一款可视化的Memcached管理与监控工具,使用PHP开发,体积小,操作简单. 主要功能: 服务器参数监控:STATS.SET ...

  4. php用explode,可以提供多个字符作为分割符来进行分割数组吗?

    explode — 使用一个字符串分割另一个字符串, 它的函数原型如下: array explode ( string $delimiter , string $string [, int $limi ...

  5. PHP中的命名空间(namespace)及其使用详解

    PHP中的命名空间(namespace)及其使用详解 晶晶 2年前 (2014-01-02) 8495次浏览 PHP php自5.3.0开始,引入了一个namespace关键字以及__NAMESPAC ...

  6. 【Objective-C】06-点语法

    前言 在Java中,我们可以通过"对象名.成员变量名"来访问对象的公共成员变量,这个就称为"点语法".比如: 1.在Student类的第2行定义了一个公共的成员 ...

  7. 13个实用的Apache Rewrite重写规则

    1.去掉域名中的www标记 复制代码 代码如下: RewriteCond %{HTTP_HOST} !^jb51\.net$ [NC]RewriteRule .? http://jb51.net%{R ...

  8. linux设置时间的方法

    0. date -R  中国上海的时区是+8000 1.tzselect 设置时区,依次选择5,9,1,1(如果时区不一样,执行下面的命令得到之后时间是不一样的) 2.sudo ntpdate asi ...

  9. traceroute/tracert--获取网络路由路径

    traceroute 是用来检测发出数据包的主机到目标主机之间所经过的网关数量的工具.traceroute 的原理是试图以最小的TTL发出探测包来跟踪数据包到达目标主机所经过的网关,然后监听一个来自网 ...

  10. Acme Corporation UVA - 11613 拆点法+最大费用最大流(费用取相反数)+费用有正负

    /** 题目:Acme Corporation UVA - 11613 拆点法+最大费用最大流(费用取相反数)+费用有正负 链接:https://vjudge.net/problem/UVA-1161 ...