简体   繁体   English

检索 Azure VM FQDN

[英]Retrieve Azure VM FQDN

I am looking for a way to check if we have Azure Virtual machines that are not domain joined.我正在寻找一种方法来检查我们是否有未加入域的 Azure 虚拟机。 I am looking for a PS command or script to query the entire Azure VM estate and return a list with all VMs ideally in csv format.我正在寻找一个 PS 命令或脚本来查询整个 Azure VM 资产并返回一个包含所有 VM 的列表,最好是 csv 格式。 Those VMs that are not domain joined will be a subject to another task, of course - join to the domain.当然,那些未加入域的虚拟机将成为另一项任务的主题 - 加入域。

The command which works fine to retrieve the FQDN is可以正常检索 FQDN 的命令是

Get-WmiObject -Namespace root\cimv2 -Class Win32_ComputerSystem | Select Name, Domain

However, this works only for individual machine.但是,这仅适用于单个机器。 I was told to use foreach loop to query all VMs but I don't know how.我被告知使用 foreach 循环来查询所有虚拟机,但我不知道如何。

Psremoting is enabled and tested OK, same for WSMAN. Psremoting 已启用并且测试正常,对于 WSMAN 也是如此。

Here is the foreach command to find the list of VM's and domain names.这是用于查找 VM 和域名列表的 foreach 命令。

connect-azaccount
$vmlist=get-azvm | select -Property Name
foreach( $item in $vmlist){
Get-WmiObject  -Namespace root\cimv2 -ComputerName $item  -Class Win32_ComputerSystem | Select Name, Domain
}

在此处输入图像描述

If you want to use get-wmiobject cmdlet you need to enable wsman Here is the document for using enabling wsman .如果要使用get-wmiobject cmdlet,则需要启用wsman这是使用启用wsman的文档。

Instead of wsman you can even run get-computerinfo if you run this command, you will get a property called csdomain which is the information of domain name.如果你运行这个命令,你甚至可以运行get-computerinfo而不是wsman ,你会得到一个名为csdomain的属性,它是域名的信息。

在此处输入图像描述

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

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