February 2019
Intermediate to advanced
626 pages
15h 51m
English
The following function sets a computer description by modifying values in the registry:
function Set-ComputerDescription {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[AllowEmptyString()]
[String]$Description
)
$erroractionpreference = 'Stop'
try {
$path = 'HKLM:\System\CurrentControlSet\Services\LanmanServer\Parameters'
if ((Get-Item $path).GetValue('srvcomment') -ne $Description) {
if ($Description) {
Set-ItemProperty $path -Name 'srvcomment' -Value $Description
} else {
Remove-ItemProperty $path -Name 'srvcomment'
}
}
} catch {
throw
}
}
When the function interacts with the registry, it does so using the following commands:
Testing the actions undertaken by ...
Read now
Unlock full access