Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Powshell looks up the computer name and account in the domain

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

One of the requirements we get today is to find the statistics of computer accounts in the specified OU. It turns out that I often use Get-Aduser to find the domain account, and one of the commands I can think of is Get-Adcomputer.

Then can not help but open the www.bing.com to find, generally I am still used to using this search engine. There are not many people playing powershell in China.

Https://docs.microsoft.com/en-us/powershell/module/activedirectory/get-adcomputer?view=winserver2012-ps

These are some examples given by Microsoft officials.

My approach is to first use the following command to see all the properties of a computer account

Get-Adcomputer-Identity computer name-Properties *

It turned out to be a lot, and then I flipped through it and thought that Name and LastLogonDate should be useful. In fact, there are some methods on the Internet, but I just don't bother to use them. Then I generated the following command, which is also very practical.

Get-ADComputer-Filter-SearchBase "ou,dc=, dc=, dc="-Properties that ou= is looking for | Select-Object Name,LastLogonDate | out-file c:\ computername.txt

There are two points to note:

First, you need to use administrator privileges to open powershell, otherwise you cannot write to the local file.

Second, remove the out-file first, look at the results and then generate the file.

Searchbase this parameter does not understand, you can search more, in fact, it is very simple.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report