Answer the question
In order to leave comments, you need to log in
How to correctly compose and use a script on GPO Server 2016 for users to write the "description" column of the computer in the OU Active Directory?
Good afternoon. I found a couple of scripts on the net that should write information about the current account used on the PC in the "description" column of the PC. But there is no way to get them to work.
On Error Resume Next
Dim adsinfo, ThisComp, oUser
Set adsinfo = CreateObject("adsysteminfo")
Set ThisComp = GetObject("LDAP://" & adsinfo.ComputerName)
Set oUser = GetObject("LDAP://" & adsinfo.UserName)
Thiscomp.put "description", "Logged on: " + oUser.cn + " " + CStr(Now)
ThisComp.Setinfo
On Error Resume Next
Dim adsinfo, ThisComp, oUser
Set adsinfo = CreateObject("adsysteminfo")
Set ThisComp = GetObject("LDAP://" & adsinfo.ComputerName)
Set oUser = GetObject("LDAP://" & adsinfo.UserName)
Thiscomp.put "description", ">> Logged off: " + oUser.cn + " " + CStr(Now)
ThisComp.Setinfo
$USERDNSDOMAIN = $env:USERDNSDOMAIN
$COMPUTERNAME = $env:COMPUTERNAME
$ObjectHash = @{}
$ObjectHash.UserName = $env:USERNAME
$ObjectHash.UserDomain = $USERDNSDOMAIN
$ObjectHash.DateTime = "{0:dd.MM.yyyy-HH:mm:ss}" -f $(Get-Date)
$ObjectHash.Console = ([Boolean]$((query.exe SESSION | findstr.exe ">console") -match $env:USERNAME)).ToString()
$ObjectHash.PSversion = $Host.Version.Major.ToString()
$ObjectHash.MACAddress = (Get-WmiObject Win32_NetworkAdapterConfiguration -Filter "IPEnabled = $True" | sort IPConnectionMetric | select -First 1).MACAddress
$ObjectHash.Memory = [string]$((Get-WmiObject CIM_PhysicalMemory | measure -Property Capacity -Sum).Sum/1GB)+"GB"
$ObjectHash.Processor = (Get-WmiObject Win32_Processor).Name
$ObjectHash.Battery = (Get-WmiObject Win32_Battery).DeviceID
$ObjectHash.BiosSN = (Get-WmiObject Win32_BIOS).SerialNumber
$ObjectHash.SystemManufacturer = (Get-WmiObject Win32_ComputerSystem).Manufacturer
$ObjectHash.SystemModel = (Get-WmiObject Win32_ComputerSystem).Model
$select = "UserName,UserDomain,DateTime,Console,PSversion,MACAddress,Memory,Processor,Battery,BiosSN,SystemManufacturer,SystemModel" -split ","
if([int]$Host.Version.Major -ge 3){
$Description = New-Object -TypeName PSCustomObject -Property $ObjectHash | select $select | ConvertTo-Json -Compress
} else {
$Description = '{' + $(($select | % {'"'+"$($_)"+'"'+":"+'"'+"$($ObjectHash.$($_))"+'"'}) -join ",") + '}'
}
if(!$Description){$Description = "Null"}
$DirectoryEntry = New-Object System.DirectoryServices.DirectoryEntry
$USERDNSDOMAIN_DN = $DirectoryEntry.distinguishedName
$Root = [ADSI]"LDAP://$USERDNSDOMAIN/$USERDNSDOMAIN_DN"
$Root
$SearchPC = new-object System.DirectoryServices.DirectorySearcher($Root)
$SearchPC.Filter = "(&(objectClass=computer)(Name=$COMPUTERNAME))"
$Computer = [ADSI]$($SearchPC.FindOne().Path)
$Computer.put("Description",$Description)
$Computer.put("info",$Description)
# Если на любом этапе в скрипте возникла ошибка, не изменяем описание компьютера в AD
if($error.count -ge 1){exit}
# Если не было ни одной ошибки, изменяем описание компьютера в AD
$Computer.SetInfo()
exit
Answer the question
In order to leave comments, you need to log in
And here, the reviewer - habrahabr.ru/company/xakep/blog/254119
Well, for harsh bearded programmers, there is emacs + org-mode :-)
I would also write myself. Essentially 1 employee model, and one arrival and departure time table
As a matter of fact it is possible to make a DB on mysql and application for management.
If suddenly anyone is interested, I found for myself www.kimai.org/download
Today we have been testing all day, so far we like it. The file needs to be processed quite a bit. And the best part is that it's a free solution :)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question