温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》
  • 首页 > 
  • 教程 > 
  • 服务器 > 
  • 系统运维 > 
  • 怎么样查找域内所有的Windows Server 2012 R2的服务器,并区分出哪些是物理机,那些是虚拟机?

怎么样查找域内所有的Windows Server 2012 R2的服务器,并区分出哪些是物理机,那些是虚拟机?

发布时间:2020-03-31 14:55:39 来源:亿速云 阅读:490 作者:三月 栏目:系统运维

独立主机即Dedicated Server,是指客户独立租用一台服务器来展示自己的网站或提供自己的服务,比虚拟主机有空间更大,速度更快,CPU计算独立等优势,当然价格也更贵。今天,亿速云小编给大家介绍一种基本思路来解决这个问题:

怎么样查找域内所有的Windows Server 2012 R2的服务器,并区分出哪些是物理机,那些是虚拟机?

通过使用Get-Adcomputer和Get-Wmiobject 组合来实现。

思路是这样的,先看一台服务器的属性值有什么可用利用的。


[12r2-dc]: PS C:\> Get-ADComputer -Identity 12r2-dc -Properties *



AccountExpirationDate                :

accountExpires                       : 9223372036854775807

AccountLockoutTime                   :

AccountNotDelegated                  : False

AllowReversiblePasswordEncryption    : False

AuthenticationPolicy                 : {}

AuthenticationPolicySilo             : {}

BadLogonCount                        : 0

badPasswordTime                      : 0

badPwdCount                          : 0

CannotChangePassword                 : False

CanonicalName                        : abc.com/Domain Controllers/12R2-DC

Certificates                         : {System.Security.Cryptography.X509Certificates.X509Certificate}

CN                                   : 12R2-DC

codePage                             : 0

CompoundIdentitySupported            : {False}

countryCode                          : 0

Created                              : 10/9/2016 10:29:00 PM

createTimeStamp                      : 10/9/2016 10:29:00 PM

Deleted                              :

Description                          :

DisplayName                          :

DistinguishedName                    : CN=12R2-DC,OU=Domain Controllers,DC=abc,DC=com

DNSHostName                          : 12R2-DC.abc.com

DoesNotRequirePreAuth                : False

dSCorePropagationData                : {10/9/2016 10:29:03 PM, 12/31/1600 4:00:01 PM}

Enabled                              : True

HomedirRequired                      : False

HomePage                             :

instanceType                         : 4

IPv4Address                          : 169.254.15.118

IPv6Address                          :

isCriticalSystemObject               : True

isDeleted                            :

KerberosEncryptionType               : {RC4, AES128, AES256}

LastBadPasswordAttempt               :

LastKnownParent                      :

lastLogoff                           : 0

lastLogon                            : 131498622097210925

LastLogonDate                        : 9/10/2017 11:04:43 PM

lastLogonTimestamp                   : 131495834837332604

localPolicyFlags                     : 0

Location                             :

LockedOut                            : False

logonCount                           : 1860

ManagedBy                            :

MemberOf                             : {CN=Pre-Windows 2000 Compatible Access,CN=Builtin,DC=abc,DC=com, CN=Cert

                                       Publishers,CN=Users,DC=abc,DC=com}

MNSLogonAccount                      : False

Modified                             : 9/12/2017 7:23:19 PM

modifyTimeStamp                      : 9/12/2017 7:23:19 PM

msDFSR-ComputerReferenceBL           : {CN=12R2-DC,CN=Topology,CN=Domain System

                                       Volume,CN=DFSR-GlobalSettings,CN=System,DC=abc,DC=com}

msDS-GenerationId                    : {45, 30, 43, 189...}

msDS-SupportedEncryptionTypes        : 28

msDS-User-Account-Control-Computed   : 0

Name                                 : 12R2-DC

nTSecurityDescriptor                 : System.DirectoryServices.ActiveDirectorySecurity

ObjectCategory                       : CN=Computer,CN=Schema,CN=Configuration,DC=abc,DC=com

ObjectClass                          : computer

ObjectGUID                           : bf0a2518-aa9c-4cb9-ab8e-09be04b3e27b

objectSid                            : S-1-5-21-2770570338-4234891044-2636713416-1001

OperatingSystem                      : Windows Server 2012 R2 Standard

OperatingSystemHotfix                :

OperatingSystemServicePack           :

OperatingSystemVersion               : 6.3 (9600)

PasswordExpired                      : False

PasswordLastSet                      : 8/20/2017 4:58:11 PM

PasswordNeverExpires                 : False

PasswordNotRequired                  : False

PrimaryGroup                         : CN=Domain 

看到这里就知道利用哪个属性值了,过滤一下,用一个通配符表达式或是任何一个能把这个值抓住的条件就可以,再用一个选择语句把名字选择出来。

$computer = Get-ADComputer -Filter {operatingsystem -like "*20*"} | select -ExpandProperty name

然后运行了一下Get-Wmiobject,结果如下:

[12r2-dc]: PS C:\> Get-WmiObject -Class win32_computersystem



Domain              : abc.com

Manufacturer        : Microsoft Corporation

Model               : Virtual Machine

Name                : 12R2-DC

PrimaryOwnerName    : Windows User

TotalPhysicalMemory : 2094039040


然后想到,如果把变量$computer传递进来,再把两个属性暴露出来,就会产生一个结果集,当然,你愿意输出到文件自己再用管道符输出就是了。


Invoke-Command -ComputerName $computer {Get-WmiObject win32_computersystem} -ErrorAction SilentlyContinue | select name,model | sort model



结果就是:

Name                                                        Model

----                                                        -----

12R2-SCCM                                                   Virtual Machine

总结:无论是独立主机还是虚拟主机,两者实现的功能在很多方面的需求是可以一致的,主要区别在于:1,自定义软件装备;  2,大容量存储和备份; 3,需求树立很多网站者 。 因此,用户应该根据自己的实际需求去选择是用物理机还是虚拟机比较好,亿速云的服务器机房遍布多个国家,无论是虚拟机还是物理机在业内都具有一定的口碑和优势,可以满足大部分用户的要求!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI