简体   繁体   English

Convert VBScript Code to Power Shell Code 从 windows 10 工作站写入 Active Directory 计算机帐户描述中的值

[英]Convert VBScript Code to Power Shell Code to write the value on the Active Directory computer account description from the windows 10 workstation

I'm trying to write the value on the Active Directory computer account description from the windows 10 workstation.我试图在 windows 10 工作站的 Active Directory 计算机帐户描述中写入值。 I success to use this VB Script on startup up group policy on all workstations to write some values (Computer hardware specs) on the Active Directory computer account description.我成功地在所有工作站上启动组策略时使用此 VB 脚本在 Active Directory 计算机帐户描述中写入一些值(计算机硬件规格)。

Set objSysInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & objSysInfo.UserName)
Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName)
objComputer.Description = "Tested PC"
objComputer.SetInfo

is it possible to use Set-ADComputer -Identity computername -Description "Test" from windows 10 workstation without install any module or any other tool.是否可以使用Set-ADComputer -Identity computername -Description "Test" from windows 10 workstation 而无需安装任何模块或任何其他工具。

在此处输入图像描述

Best regards最好的祝福

You can use the built-in [ADSI] classes to search AD for the computer object and set attributes:您可以使用内置的[ADSI]类在 AD 中搜索计算机 object 并设置属性:

$filter = "(&(objectCategory=computer)(objectClass=computer)(cn=$env:COMPUTERNAME))"
$computer = [ADSI](([adsisearcher]$filter).FindOne().Path)
$computer.description = $NewDescription
$computer.setinfo()

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

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