WindowsServer

Powershell – Change computer description

To continue in Powershell posts, we will see how to change the local description of the server. Not in Active Directory attribute but on the computer itself.

System Description

The local description is set is the WMI of the server. In the class Win32_OperatingSystem. To change it, we need to get the objects, set the new content and save the modification.

$OSWMI=Get-WmiObject -class Win32_OperatingSystem
$OSWMI.Description="My Server"
$OSWMI.put()

Remote

It is possible to modify the description on a remote computer, however, we need to adapt the script if the string is store in a variable.

With the Invoke-Command we add the parameter –ArgumentList, so that our variable content will be available on the execution on the remote host.

$myDescription="My Server"
Invoke-Command -ComputerName $lServerName -ScriptBlock {$OSWMI=Get-WmiObject -class Win32_OperatingSystem;$OSWMI.Description=$args[0];$OSWMI.put() } -ArgumentList($myDescription)

More

You can get more information about Win32_OperatingSystem class here

Share