Important Notice: On February 29th, this community was put into read-only mode. All existing posts will remain but customers are unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

Set Computer Description Tool (PowerShell)

This isn't really a question, but more of a follow up to a previous inquiry I had to support and I thought I'd share it so others can benefit.

I have developed a powershell script (as I learn PS) that can set the selected machine's computer description (local description) and then automatically trigger a Computer Info scan that will update in PDQ Inventory. The code is below, you may need to adjust it in a few places as necessary.

The code is below. I am sorry if zendesk butchers the formatting. Save below as a powershell file (.ps1) and then make a custom tool in PDQ Inventory (File > Preferences > Custom Tools) with the syntax:

PowerShell PathToSavedFile.ps1 %TARGETHOSTNAME%

 

=====CODE BELOW======

#Set Computer Description
param([String]$compname="") #Must be the first statement in your script
if ($compname -eq "") {
    Write-Error "Computer name is a required parameter."
    exit 1
}
$OSValues = Get-WmiObject -class Win32_OperatingSystem -computername $compname
[void][Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')
$title = 'Set Computer Description'
$msg = "Computer: $compname`nCurrent Description: "+$OSValues.Description+"`nEnter new description:"
$text = [Microsoft.VisualBasic.Interaction]::InputBox($msg, $title)
if ($text -eq "") {
   Write-Error "Computer description cannot be empty."
   exit 2
}
$OSValues.Description = $text;
$OSValues.put()
#remove line below if not using PDQ Inventory
& "C:\Program Files (x86)\Admin Arsenal\PDQ Inventory\PDQInventory.exe" ScanComputers -ScanProfile "Computer Info" -Computers $compname
#& at start means interpret as command not string
exit 0

0

Comments

3 comments
Date Votes
  • Very cool. Thanks for sharing.

    0
  • Very nice thanks, cool custom tool.

    More brain storm for custom tools, they are nice.

    Would be nice to read what kind of custom tools admins has created. 

    0
  • Help ...

    Cant make it work in PDQ - Central Server / Client -mode??

    Best tool ever, but now I dont know what is the problem, server 2012r2 and client Windows 10, all with same PowerShell version 5

    0