Hi all,
I would like to create a script that modifies the description field of the computers in my domain.
I want the ps1 file to query the AD in order to retrieve the last user (win2000) connected and the IP address and then register it in the description field of the computer object.
for exemple :
Script :
CHECK COMPUTER 1 => user “TATA” found, ip adresse : “10.0.0.1” found , copy the information and paste in description field of “Computer 1”
CHECK COMPUTER 2 => user “TOTO” found, ip …
I don’t want a script that runs on host machines that don’t have RSAT tools, I’ll run the script every 20 minutes
For moment i have this :
Import-Module ActiveDirectory
REMOTE COMPUTER
$ComputerName = ‘P5113931’
OR
LOCAL COMPUTER
#ComputerName = (Get-WmiObject -Class Win32_ComputerSystem -Property Name).Name
$a = Get-Date
$b = $a.ToShortDateString()
$c = $a.ToShortTimeString()
$d = Get-WmiObject -computername $ComputerName Win32_Computersystem | Select -Expand modelif ($d -eq $null) {$d = ‘0000’}
#$e = $d -replace ‘\D+(\d+)\D+’,‘$1’
$Description = “Damien script lounes * $b $c * $d”Set-ADComputer $ComputerName -description $Description
i can modify one per one but is not my objectif.
Thank a lot !