收集磁盘分区信息(总量、可用、已用、百分比)导出到csv
#############################脚本功能及说明#################################################
#该脚本用来收集磁盘分区总大小、可用空间、已用空间、已用空间百分比,输出到csv
############################################################################################
$file_server = "Serverlist.txt"
$result = "DiskInfor.csv"
$CurrentPath = $MyInvocation.MyCommand.Path.substring(0,$MyInvocation.MyCommand.Path.LastIndexOf('\')+1)
$server_list = $CurrentPath + $file_server
$diskPath = $currentpath + $result
$servers = Get-Content $server_list
$UserName = "administrator"
#$UserName = "erpadmin"
$ics=$null
Foreach ($server in $servers)
{
$servername = $server.split(",")[0]
$serverpass = $server.split(",")[1]
#net use \\$servername $serverpass /user:$UserName |out-null
$Password = ConvertTo-SecureString $serverpass -AsPlainText –Force
$cred = New-Object System.Management.Automation.PSCredential($UserName,$Password)
Write-Host $servername -ForegroundColor Green
$ic = invoke-command -ComputerName $servername -Credential $cred -ScriptBlock {param($servername)
function disksize ($servername)
{
$disks = Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=3" -computer $servername
$results=@()
foreach ($disk in $disks)
{
$deviceid = $disk.deviceid
$size = ($disk.size/1024/1024/1024).tostring("f1")
$free = ($disk.freespace/1024/1024/1024).tostring("f1")
$used = $size-$free
$perc = "{0:p}" -f($disk.freespace/$disk.size)
$result=""|select name,idd,size,free,used,perc
$result.name = $servername
$result.idd = $deviceid
$result.size = $size
$result.free = $free
$result.used = $used
$result.perc = $perc
$results += $result
}
$results
}
disksize $servername
} -ArgumentList $servername
$ics += $ic
$ics|select name,idd,size,free,used,perc |Export-Csv $diskPath -NoTypeInformation
}
#$results |Export-Csv $memPath -NoTypeInformation
#net use * /del /y |out-null
#cmd /c pause
收集磁盘分区信息(总量、可用、已用、百分比)导出到csv的更多相关文章
- 收集计算机分区信息,去除列中的重复值(Excel)(空行)
收集计算机分区信息 $servers = gc D:\serverlist.txt $result = $results = $null $results = @() foreach ($server ...
- Windows下用C++删除磁盘分区信息
做一个能对U盘重新分区的小工具,使用该方法删除U盘中原有的分区表. bool CCesDiskDll::DestroyDisk(unsigned char deviceNumber) { DWORD ...
- powershell 常用命令之取磁盘分区信息
//查看mac 地址 PS C:\Users\yyy> get-wmiobject -class Win32_NetworkAdapterConfiguration -namespace &qu ...
- fdisk -l查看硬盘分区信息及硬盘分区介绍
原文:https://blog.csdn.net/a1809032425/article/details/79692035 linux fdisk 命令和df区别是什么? fdisk工具是分区工具:d ...
- Linux系统磁盘分区、删除分区、格式化、挂载、卸载、开机自动挂载的方法总结
Linux系统按照MBR(Master Boot Record)传统分区模式: 注意:传统的MBR(Master Boot Record)分区方式最大只能分2T容量的硬盘,超过2T的硬盘一般采用GPT ...
- Linux命令学习—— fdisk -l 查看硬盘及分区信息
Linux命令学习(3)-- fdisk -l 查看硬盘及分区信息注意:在使用fdisk命令时要加上sudo命令,否则什么也不能输出linux fdisk 命令和df区别是什么? fdisk工具是分区 ...
- 调整Linux磁盘分区的大小的方法
昨天数据入库时,一直报错,说磁盘满了,,df -h 一看,发现/目录下只有50G空间,已使用49G:我的程序和dbss都安装在/目录下,ftp到的数据放在/data下的一个子目录下,分解完的 ...
- Linux中磁盘分区——理论篇
Linux中磁盘分区——理论篇 现在主流的分区的方式有两种——MBR分区和GPT分区,本文将着重介绍MBR分区底层原理,及用相关命令验证相关原理 Linux中磁盘分区理论篇 为什么要对磁盘进行分区 M ...
- linux磁盘分区格式化-fdisk命令工具
本文主要讲述使用fdisk工具对磁盘进行分区和格式化的方法 首先要明确分区是针对磁盘进行的操做,磁盘分区会创建分区表,类似vda,sda的是磁盘,vda1,sda1的是分区 1.查看磁盘分区状态 1. ...
随机推荐
- 浏览器因cookie设置HttpOnly标志引起的安全问题
1.简介 如果cookie设置了HttpOnly标志,可以在发生XSS时避免JavaScript读取cookie,这也是HttpOnly被引入的 原因.但这种方式能防住攻击者吗?HttpOnly标志可 ...
- php smarty section使用
文件:section.tpl <html> <head> <title></title> </head> <body> {sec ...
- php获取请求的方式(get/post)
$request_method = $_SERVER['REQUEST_METHOD'];//用什么方式访问 get post
- 汇编语言第二版 程序在dos中执行情况.P86-87
假设程序要被dos系统加载到sa:0000的内存中,在这个地址的内存开始会有256个字节的PSP程序,用于加载程序和dos系统的通信.ds中的地址为sa. 真正的程序会在这256个字节之后.所以真正程 ...
- 环信_EaseUI 使用指南
EaseUI 使用指南 简介 EaseUI 封装了 IM 功能常用的控件(如聊天会话.会话列表.联系人列表).旨在帮助开发者快速集成环信 SDK. 源码地址: EaseUI:https://githu ...
- USCAO3.26Sweet Butter(SPFA)
最短路复杂度估计错误 以为SPFA是N*m的 用了dij超时 用SPFA直接跑就好了 O(k*e) K 一般为2,3: /* ID: shangca2 LANG: C++ TASK: butter * ...
- Hadoop MapReduce 二次排序原理及其应用
关于二次排序主要涉及到这么几个东西: 在0.20.0 以前使用的是 setPartitionerClass setOutputkeyComparatorClass setOutputValueGrou ...
- apache开源项目--lucence
Lucene 是apache软件基金会一个开放源代码的全文检索引擎工具包,是一个全文检索引擎的架构,提供了完整的查询引擎和索引引擎,部分文本分析引擎.Lucene的目的是为软件开发人员提供一个简单易用 ...
- Apache虚拟主机(vhost)配置教程
使用apache来配置虚拟主机,在单一系统上运行多个网站. 现在很多linux主机使用apache作为web服务器的,大部分是基于这个原理来配置虚拟主机的. 下面就windows下以apache 2. ...
- C#使用SQLite出错:无法加载 DLL“SQLite.Interop.dll”,找不到指定的模块
在SQLite官方下载了System.Data.SQLite,编写如下测试代码: 复制内容到剪贴板 程序代码 using (SQLiteConnection conn = new SQLiteConn ...