知识点:
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. mac ssh 命令

    https://www.cnblogs.com/littleBit/p/5362806.html 1.终端命令 1.打开Mac的命令终端,检查是不是用root登陆,如果不是的话,就输入命令:sudo ...

  2. C 语言文件拷贝

    相关的方法: int fputs(const char*s,FILE *stream); int gets(char *s,int size,FILE *stream); 具体代码如下 /** *@a ...

  3. spring boot下WebSocket消息推送(转)

    原文地址:https://www.cnblogs.com/betterboyz/p/8669879.html WebSocket协议 WebSocket是一种在单个TCP连接上进行全双工通讯的协议.W ...

  4. 点滴积累【C#】---对上传文件的路径进行加密,以免将路径暴露在浏览器上,避免一些安全隐患!

    效果: 描述: 本事例是为解决在上传或下载文件时避免将路径暴露在外.在上传时将路径进行加密保存到DataTable或数据库中,在下载是再读取DataTable中加密数据进行解密下载. 代码: [前台代 ...

  5. Atitit.html解析器的选型 jsoup nsoup ,java c# .net 版本

    Atitit.html解析器的选型 jsoup nsoup ,java c# .net 版本 1. 框架选型的要求1 1.1. 文档多1 1.2. 跨平台1 2. html解析器特性:1 2.1. j ...

  6. CMSGC造成内存碎片的解决方法

    我们知道,CMSGC在老生代回收时产生的内存碎片会导致老生代的利用率变低:或者可能在老生代总内存大小足够的情况下,却不能容纳新生代的晋升行为(由于没有连续的内存空间可用),导致触发FullGC.针对这 ...

  7. IntelliJ IDEA代码编码区提示库源不匹配字节码解决办法

    在使用IntelliJ IDEA进行开发时,可能会在代码编辑区出现此提示:library source does not match the bytecode for class HelloWorld ...

  8. love2d教程34--thread模块

    love的thread是一个单独的lua运行环境,与主线程平行.因此可以用线程来处理 处理复杂的计算,不过由于隔离,线程不能访问主线程的变量和方法,而且进程 间通信也受限.   可以在线程里共享lov ...

  9. JVM Specification 9th Edition (2) Chapter 1. Introduction

    Chapter 1. Introduction 翻译太累了,我就这样的看英文吧. 内容列表 1.1. A Bit of History 1.2. The Java Virtual Machine 1. ...

  10. web.py使用要点

    这几天有一个构建restful services的需求,我采用了web.py,之前并没有使用过,但在使用中确实给我带来了很多惊喜.当然,最大的惊喜就是简单,方便.之前开发restful服务的时候,采用 ...