Powershell Get File/Disk Size
知识点:
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的更多相关文章
- Powershell split file
#网上所得非原创 function split($inFile, $outPrefix, [Int32] $bufSize){ $stream = [System.IO.File]::OpenRead ...
- Powershell About File System
File System Rights Get-Acl $sharepath | select -expand access | where { !$_.IsInherited -AND $_.file ...
- C# calculate disk size
static void Main(string[] args) { string dir = @"C:\"; string[] dirs=Directory.GetDirector ...
- Linux下获取硬盘使用情况
Linux下获取硬盘使用情况[总结] 1.前言 在嵌入式设备中,硬盘空间非常有限,在涉及到经常写日志的进程时候,需要考虑日志的大小和删除,不然很快就硬盘写满,导致日志程序崩溃.为了捕获硬盘写满的异常场 ...
- linux下获取硬盘使用情况[总结]
1.前言 在嵌入式设备中,硬盘空间非常有限,在涉及到经常写日志的进程时候,需要考虑日志的大小和删除,不然很快就硬盘写满,导致日志程序崩溃.为了捕获硬盘写满的异常场景,我们需要在写日志过程中判断硬盘空间 ...
- [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, ...
- Windows Azure Storage (20) 使用Azure File实现共享文件夹
<Windows Azure Platform 系列文章目录> Update 2016-4-14.在Azure VM配置FTP和IIS,请参考: http://blogs.iis.net/ ...
- The commands of Disk
The commands of Disk fdisk( the disk size is less 2TB) fdisk - partition table manipulator for Linux ...
- Keil AGDI Header File
#ifndef __AGDI__INCED___ #define __AGDI__INCED___ //---Revision History: --------------------------- ...
随机推荐
- macbook使用“终端”远程登录linux主机
登录mac系统后,依次打开顶部菜单,“前往” -> “应用程序” -> “实用工具” -> “终端”,如下图: 在打开的终端页面,输入如下代码: ssh user@hostnam ...
- POJ 1258:Agri-Net(最小生成树&&prim)
Agri-Net Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 38918 Accepted: 15751 Descri ...
- error: Semantic Issue: Interface type cannot be statically allocated
转自:http://hongmin118.iteye.com/blog/1333524 error: Semantic Issue: Interface type cannot be statical ...
- 从Python的角度来看编码与解码
导语: Python2和Python3中,因为默认字符集的不同而造成的麻烦,简直是程序员的梦魇!要彻底告别这个麻烦,就需要从本质上来理解编码和解码. 为什么要有编码? 对于不会英文的中国人来说,将英文 ...
- PHP命名空间规则解析及高级功能
日前发布的PHP .3中,最重要的一个新特性就是命名空间的加入.本文介绍了PHP命名空间的一些术语,其解析规则,以及一些高级功能的应用,希望能够帮助读者在项目中真正使用命名空间. 在这里中我们介绍了P ...
- 0053 用注解方式配置Spring MVC
按照0052中的办法,如果一个站点设计有1000个请求,那就得写1000个controller,还得配置1000个<bean id="helloController" cla ...
- jxta-amalto
前几天在网络上搜索jxta的消息,发现jxta 2.8x已经启动了,官方地址http://chaupal.github.io/ 在浏览其邮件列表时,意外发现一老外基于jxta 2.6修改的一版, 可在 ...
- python笔记9 : 多线程
基础: 什么是进程(process)? 每一个程序的内存是独立的,例如:world不能访问QQ. 进程:QQ是以一个整体的形式暴露给操作系统管理,里面包含了各种资源的调用(内存管理.网络接口调用等). ...
- 【vijos】1629 八(容斥原理+dfs)
https://vijos.org/p/1629 本来是想出来了的,,,,但是有个地方写挫了一直没发现,sad 就是dfs的时候我传的pos传错了QAQ 这题用容斥很好想 首先在区间[l, r]能被a ...
- 2014-04-17-网易有道-研发类-笔试题&參考答案
一套卷子,共10道小题,3道编程大题 一.填空&选择 1.选择:给了一个递归求Fibonacci的代码,问算法复杂度 指数复杂度 2.选择:忘记了,应该不难 3.选择:给你52张除掉大小王的扑 ...