简体   繁体   English

Powershell 列出所有域连接主机的脚本

[英]Powershell Script to list all Domain connected hosts

I'm busy writing a script as a project to Audit Windows Servers for PCI compliance, One of the things my project lead has asked me to attempt to get to try to get a list of all hosts that are connected to a domain, however this script needs to be able to be run on any windows server without being able to import any modules, so I'm stuck with whatever tool already exists on a bare machine.我正忙着编写一个脚本作为项目来审核 Windows 服务器的 PCI 合规性,我的项目负责人要求我尝试获取连接到域的所有主机的列表之一,但是这个脚本需要能够在任何 windows 服务器上运行而不能导入任何模块,所以我坚持使用裸机上已经存在的任何工具。

Ive already written parts of the script that can rely on the 'active directory' modules but I also need to find a way to get information without any DNS or Domain roles installed.我已经编写了可以依赖“活动目录”模块的部分脚本,但我还需要找到一种无需安装任何 DNS 或域角色即可获取信息的方法。 The closest I can get to achieving this is by using the 'netdom' command however this relies on usernames and passwords that I cannot query for in the auditing script.我最接近实现这一点的是使用“netdom”命令,但这依赖于我无法在审计脚本中查询的用户名和密码。

Ive tried tools like nslookup and a few other things I've come across while looking for answers online, but most of it seems to rely on modules that I cannot install on the machines that the script will need to run on.我尝试过 nslookup 之类的工具以及我在网上寻找答案时遇到的其他一些东西,但其中大部分似乎依赖于我无法安装在脚本需要运行的机器上的模块。

Does anyone know if this can actually be done?有谁知道这是否真的可以做到? and if so how can I achieve this?如果是这样,我怎样才能做到这一点?

Edit: for a bit more clarity, I need a way to get a list of all machines in the domain from machines that are NOT a domain controller and I cannot alter these machines at all.编辑:为了更清楚一点,我需要一种方法从不是域 controller 的机器中获取域中所有机器的列表,我根本无法更改这些机器。

As per boxdog's comment "([adsisearcher]"objectcategory=computer").findall()" command works just fine根据 boxdog 的评论 "([adsisearcher]"objectcategory=computer").findall()" 命令工作得很好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM