Created
May 25, 2026 15:18
-
-
Save Geofferey/2d71e2904aa855c9b663142d77224baf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Set-Attribute { | |
| param ( | |
| [string]$Attribute, | |
| [string]$Value | |
| ) | |
| $searcher = New-Object System.DirectoryServices.DirectorySearcher | |
| $searcher.Filter = "(name=$env:ComputerName)" | |
| $result = $searcher.FindOne() | |
| if (-not $result) { | |
| throw "Computer object not found: $env:ComputerName" | |
| } | |
| $entry = $result.GetDirectoryEntry() | |
| $entry.Put($Attribute, $Value) | |
| $entry.CommitChanges() | |
| Write-Host "Set $Attribute to '$Value' on $env:ComputerName" | |
| } | |
| Set-Attribute -Attribute "description" -Value "Test write from computer" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment