关于获取windows系统参数方法

简介:

  前一阵写了一个获取网络内主机类型的脚本,没有写任何解释类的说明直接发上来造成好多兄弟们有很多疑问。今天就拣几个有特点的功能说明一下。

   获取windows系统或者性能参数。

   在powershell出现之前系统管理员习惯用VB来实现获取以上参数的功能(当然现在也可以),但本次文章的重点主是说powershell怎么实现获取以上参数信息,Powershell提供了很多扩展的功能可以直接访问.net框架,WMI,COM自动化和API的调用等。

   下面我们举例说明一哈通过WMI获取主机的内存信息:

   1获取本地主机空余内存大小:

1
2
[PS]  C:\>(GWMI win32_OperatingSystem).FreePhysicalMemory
1245384

   2获取本地主机的总内存大小:

1
2
[PS]  C:\>(GWMI win32_OperatingSystem).TotalVisibleMemorySize
4166596

   3如果我们想查看还能查看还有哪些类可以获取,按如下操作就可以看到:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
[PS]  C:\>GWMI win32_OperatingSystem |  Get-Member
    TypeName: System.Management.ManagementObject #root\cimv2\Win32_OperatingSystem
Name                                      MemberType   Definition
----                                      ----------   ----------
Reboot                                    Method       System.Management.ManagementBaseObject Reboot()
SetDateTime                               Method       System.Management.ManagementBaseObject SetDateTime(System.String LocalDateTi
Shutdown                                  Method       System.Management.ManagementBaseObject Shutdown()
Win32Shutdown                             Method       System.Management.ManagementBaseObject Win32Shutdown(System.Int32 Flags, Sys
Win32ShutdownTracker                      Method       System.Management.ManagementBaseObject Win32ShutdownTracker(System.UInt32 Ti
BootDevice                                Property     System.String BootDevice {get;set;}
BuildNumber                               Property     System.String BuildNumber {get;set;}
BuildType                                 Property     System.String BuildType {get;set;}
Caption                                   Property     System.String Caption {get;set;}
CodeSet                                   Property     System.String CodeSet {get;set;}
CountryCode                               Property     System.String CountryCode {get;set;}
CreationClassName                         Property     System.String CreationClassName {get;set;}
CSCreationClassName                       Property     System.String CSCreationClassName {get;set;}
CSDVersion                                Property     System.String CSDVersion {get;set;}
CSName                                    Property     System.String CSName {get;set;}
CurrentTimeZone                           Property     System.Int16 CurrentTimeZone {get;set;}
DataExecutionPrevention_32BitApplications Property     System.Boolean DataExecutionPrevention_32BitApplications {get;set;}
DataExecutionPrevention_Available         Property     System.Boolean DataExecutionPrevention_Available {get;set;}
DataExecutionPrevention_Drivers           Property     System.Boolean DataExecutionPrevention_Drivers {get;set;}
DataExecutionPrevention_SupportPolicy     Property     System.Byte DataExecutionPrevention_SupportPolicy {get;set;}
Debug                                     Property     System.Boolean Debug {get;set;}
Description                               Property     System.String Description {get;set;}
Distributed                               Property     System.Boolean Distributed {get;set;}
EncryptionLevel                           Property     System.UInt32 EncryptionLevel {get;set;}
ForegroundApplicationBoost                Property     System.Byte ForegroundApplicationBoost {get;set;}
FreePhysicalMemory                        Property     System.UInt64 FreePhysicalMemory {get;set;}
FreeSpaceInPagingFiles                    Property     System.UInt64 FreeSpaceInPagingFiles {get;set;}
FreeVirtualMemory                         Property     System.UInt64 FreeVirtualMemory {get;set;}
InstallDate                               Property     System.String InstallDate {get;set;}
LargeSystemCache                          Property     System.UInt32 LargeSystemCache {get;set;}
LastBootUpTime                            Property     System.String LastBootUpTime {get;set;}
LocalDateTime                             Property     System.String LocalDateTime {get;set;}
Locale                                    Property     System.String Locale {get;set;}
Manufacturer                              Property     System.String Manufacturer {get;set;}
MaxNumberOfProcesses                      Property     System.UInt32 MaxNumberOfProcesses {get;set;}
MaxProcessMemorySize                      Property     System.UInt64 MaxProcessMemorySize {get;set;}
MUILanguages                              Property     System.String[] MUILanguages {get;set;}
Name                                      Property     System.String Name {get;set;}
NumberOfLicensedUsers                     Property     System.UInt32 NumberOfLicensedUsers {get;set;}
NumberOfProcesses                         Property     System.UInt32 NumberOfProcesses {get;set;}
NumberOfUsers                             Property     System.UInt32 NumberOfUsers {get;set;}
OperatingSystemSKU                        Property     System.UInt32 OperatingSystemSKU {get;set;}
Organization                              Property     System.String Organization {get;set;}
OSArchitecture                            Property     System.String OSArchitecture {get;set;}
OSLanguage                                Property     System.UInt32 OSLanguage {get;set;}
OSProductSuite                            Property     System.UInt32 OSProductSuite {get;set;}
OSType                                    Property     System.UInt16 OSType {get;set;}
OtherTypeDescription                      Property     System.String OtherTypeDescription {get;set;}
PAEEnabled                                Property     System.Boolean PAEEnabled {get;set;}
PlusProductID                             Property     System.String PlusProductID {get;set;}
PlusVersionNumber                         Property     System.String PlusVersionNumber {get;set;}
Primary                                   Property     System.Boolean Primary {get;set;}
ProductType                               Property     System.UInt32 ProductType {get;set;}
RegisteredUser                            Property     System.String RegisteredUser {get;set;}
SerialNumber                              Property     System.String SerialNumber {get;set;}
ServicePackMajorVersion                   Property     System.UInt16 ServicePackMajorVersion {get;set;}
ServicePackMinorVersion                   Property     System.UInt16 ServicePackMinorVersion {get;set;}
SizeStoredInPagingFiles                   Property     System.UInt64 SizeStoredInPagingFiles {get;set;}
Status                                    Property     System.String Status {get;set;}
SuiteMask                                 Property     System.UInt32 SuiteMask {get;set;}
SystemDevice                              Property     System.String SystemDevice {get;set;}
SystemDirectory                           Property     System.String SystemDirectory {get;set;}
SystemDrive                               Property     System.String SystemDrive {get;set;}
TotalSwapSpaceSize                        Property     System.UInt64 TotalSwapSpaceSize {get;set;}
TotalVirtualMemorySize                    Property     System.UInt64 TotalVirtualMemorySize {get;set;}
TotalVisibleMemorySize                    Property     System.UInt64 TotalVisibleMemorySize {get;set;}
Version                                   Property     System.String Version {get;set;}
WindowsDirectory                          Property     System.String WindowsDirectory {get;set;}
__CLASS                                   Property     System.String __CLASS {get;set;}
__DERIVATION                              Property     System.String[] __DERIVATION {get;set;}
__DYNASTY                                 Property     System.String __DYNASTY {get;set;}
__GENUS                                   Property     System.Int32 __GENUS {get;set;}
__NAMESPACE                               Property     System.String __NAMESPACE {get;set;}
__PATH                                    Property     System.String __PATH {get;set;}
__PROPERTY_COUNT                          Property     System.Int32 __PROPERTY_COUNT {get;set;}
__RELPATH                                 Property     System.String __RELPATH {get;set;}
__SERVER                                  Property     System.String __SERVER {get;set;}
__SUPERCLASS                              Property     System.String __SUPERCLASS {get;set;}
FREE                                      PropertySet  FREE {FreePhysicalMemory, FreeSpaceInPagingFiles, FreeVirtualMemory, Name}
PSStatus                                  PropertySet  PSStatus {Status, Name}
ConvertFromDateTime                       ScriptMethod System.Object ConvertFromDateTime();
ConvertToDateTime                         ScriptMethod System.Object ConvertToDateTime();


  4 如果我们想获取远程主机的参数应该怎么操作呢只需加上-computer参数比如:

1
2
[PS]  C:\>(GWMI  -computer  bjexfe01  win32_OperatingSystem).TotalVisibleMemorySize
33543988



本文转自handsome7038 51CTO博客,原文链接:http://blog.51cto.com/lixiaosong/1357271
相关文章
|
3月前
|
Ubuntu Unix Linux
在Windows上轻松安装和使用Ubuntu的方法详解
继续点击“Continue”按钮以继续安装流程,随后选择清理磁盘并安装操作系统的选项。 接下来,在安装过程中,你需要选择时区。为了与你的地理位置相匹配,请选择中国上海作为你的时区设置。 在安装过程中,你还需要设置计算机的名称以及账号密码。请务必牢记这些信息,因为它们将作为你登录系统的凭证。
|
4月前
|
Linux Windows
Windows 10/11从官网下载ISO的方法
本文介绍了两种从微软官网下载Windows 10/11 ISO镜像的方法。一是通过修改浏览器User Agent为Linux系统,使官网提供ISO下载链接;二是使用UUPDUMP工具,从官网下载并转换为ISO格式,支持最新开发版,操作简便。
|
7月前
|
安全 数据安全/隐私保护 Windows
如何在Windows 10系统中查看已连接WiFi密码-亲测可用-优雅草卓伊凡
如何在Windows 10系统中查看已连接WiFi密码-亲测可用-优雅草卓伊凡
323 15
如何在Windows 10系统中查看已连接WiFi密码-亲测可用-优雅草卓伊凡
|
7月前
|
关系型数据库 虚拟化 UED
Omnissa Horizon Windows OS Optimization Tool 2503 - Windows 系统映像优化工具
Omnissa Horizon Windows OS Optimization Tool 2503 - Windows 系统映像优化工具
271 7
Omnissa Horizon Windows OS Optimization Tool 2503 - Windows 系统映像优化工具
|
2月前
|
运维 安全 Linux
【清爽加速】Windows 11 Pro 24H2-Emmy精简系统
“清爽加速”Windows 11 Pro 24H2 针对老旧或低配设备,通过精简系统、优化服务与简化装机流程,降低资源占用,提升运行流畅度,兼顾安全性与稳定性,让老设备也能轻松应对日常办公与轻度娱乐需求。
【清爽加速】Windows 11 Pro 24H2-Emmy精简系统
|
2月前
|
安全 数据安全/隐私保护 Windows
ZyperWin++使用教程!让Windows更丝滑!c盘飘红一键搞定!ZyperWin++解决系统优化、Office安装和系统激活
ZyperWin++是一款仅5MB的开源免费Windows优化工具,支持快速优化、自定义设置与垃圾清理,兼具系统加速、隐私保护、Office安装等功能,轻便无广告,小白也能轻松上手,是提升电脑性能的全能管家。
764 0
|
2月前
|
安全 搜索推荐 开发者
【适度精简】Windows 7 旗舰版-emmy精简系统
Windows 7旗舰版因硬件占用高、冗余组件多、兼容性差及缺乏安全更新等问题,逐渐难以满足用户需求。适度精简版通过去除无用组件、优化性能与安全性,提升老旧设备运行效率,增强兼容性与稳定性,同时保留用户熟悉的操作界面,降低学习成本,满足个性化需求,延续Windows 7的实用价值。
|
2月前
|
运维 iOS开发 Windows
windows电脑备案ios APP获取公钥和证书指纹Sha-1值的方法
在阿里云进行APP备案、在备案IOS端的环节的时候,发现需要我们将p12证书安装在电脑上,再用xcode或或钥匙串访问来获取这个证书的公钥和sha-1值。 但是大部分开发uniapp应用的同学们,或者进行发布的运维人员的电脑都是windows,无法按照阿里云的教程来获取ios的公钥和sha-1。备案就被卡主了。 这里介绍下另一个方法,就是使用香蕉云编来在线上传证书获取。如下图所示,打开香蕉云编后,找到下图这个功能
428 0
|
3月前
|
Ubuntu Linux Windows
windows11系统安装ubuntu系统详细步骤
安装后,您可以直接从商店启动应用程序来源
646 0
|
5月前
|
Ubuntu Linux 数据安全/隐私保护
Windows中安装WSL 2和Ubuntu系统的教程
回看这一路,有趣吧?你已经跨界成为了一个Windows和Linux的桥梁。期待在代码的世界里,把一切玩得风生水起!
268 13

热门文章

最新文章