PowerShell 脚本来监控 CPU、内存和磁盘使用情况: powershellCopy Code # 获取CPU使用率 $cpu = Get-Counter '\Processor(_Total)\% Processor Time' # 获取内存使用情况 $mem = Get-
# 获取CPU使用率 function Get-CpuUsage { (Get-WmiObject win32_processor | Measure-Object -Property LoadPercentage -Average).Average } 2. 设置阈值以判断何时CPU使用率过高 接下来,我们设置一个CPU使用率的阈值。当CPU使用率超过这个阈值时,我们将执行抓取线程信息的操作。 powershell # 设置CPU使用率阈值 ...
functionGet-Resources{param($computername=$env:computername)$Info=""|Select ComputerName,Memery,DiskSize,FreeDSize$info.ComputerName=$computername# Processor utilization# $cpu = gwmi win32_perfformatteddata_perfos_processor -ComputerName $computername| ? {$_.name -eq "_total"} | select -ExpandPro...
1#获取 CPU 逻辑核心数2functionget_logical_cpu_cnt () {3#get info of physical cpu cores4$cpu_info= Get-WmiObject win32_processor5#"@($cpu_info).cout" denotes the number of physical cores6return@($cpu_info).count *$cpu_info.NumberOfLogicalProcessors7}...
第一個命令會取得代表 BitsTransfer 模組的 PSModuleInfo 物件。 它會將物件儲存在 $m 變數中。 第二個命令會 Get-Content 使用Cmdlet 來取得指定路徑中指令清單檔的內容。 它會使用點表示法來取得指令清單檔案的路徑,該檔案會儲存在物件的 Path 屬性中。 輸出會顯示模組指令清單的內容。範例...
GetProcessInfos 获取所有进程的相关数据 IP4RouteTable 表示控制网络数据包路由的信息 GetSystemRunningTime 获取系统持续运行时间 GetCPULoad 获取CUP各核心使用率 GetThread 获取执行线程 GetNetAdapter 获取网络适配器信息 GetIpAddress 从ipconfig中获取各网络硬件地址信息 GetNetAdapterByDeviceID GetNetAdapterByName ...
Get-WMIObject win32_Processor //获取CPU信息 Get-WmiObject Win32_VideoController //获取显卡信息 【获取Windows产品ID】 2种方式 第一种:CMD命令行运行control system查看产品ID 第二种:CMD命令行运行powershell,输入命令查看 (Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\...
Get-Process [[-Name] <String[]>] [-Module] [-FileVersionInfo] [<CommonParameters>]PowerShell Copy Get-Process [[-Name] <String[]>] -IncludeUserName [<CommonParameters>]PowerShell Copy Get-Process -Id <Int32[]> [-Module] [-FileVersionInfo] [<CommonParameters>]Power...
Get-Modulecmdlet 检查CompatiblePSEditions属性PSModuleInfo对象的指定值,并仅返回已设置的那些模块。 备注 桌面版:基于 .NET Framework 构建,并与脚本和模块兼容,这些脚本和模块面向在 Windows 的完全占用版本(如 Server Core 和 Windows Desktop)上运行的 PowerShell 版本。
Get-WmiObject –class Win32_Processor –computername SERVER-R2 | Select-Object –property AddressWidth 問題是這些命令將生成三個不同的結果集。 您無法將所有結果直接通過管道傳輸到一個 CSV 檔(例如,用來存儲清單資料)或一個 HTML 檔(用以將此清單顯示為網頁)。 最好將這些資料綁定到一個即便是經驗不足的...