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.

Access computers in dynamic collection to set custom field w/Powershell

Hello all,

I am a complete noob when it comes to PDQ AND Powershell. I was trying to modify the PDQ script from their tutorial on inserting custom fields with powershell but can't seem to get where I need to be.

I have created a dynamic collection based on the Model of the computer. What I want to do is set the purchase year and end of life year in the custom fields I have created. Ultimately, it would probably need 'If' statements to set the year by Collection. For example, Collection 7060 would have a purchase year of 2018 and an end of life of 2025. Collection 7080 would have a purchase year of 2021 and end of life of 2028.

Any guidance would be greatly appreciated!

Tim

 

The PDQ script I am working with, minus the custom field creation since they exist:

$DBPath = "C:\programdata\Admin Arsenal\PDQ Inventory\Database.db"
$SQL = 'Select Name from Computers;'
$Computers = sqlite3.exe $DBPath $SQL

$CustomFieldName = "Department"
$CustomFieldType = "String" # Valid types - Boolean, String, Integer, Date, or DateTime

$ComputerList = @("ComputerName,$CustomFieldName")
$Computers | ForEach-Object {

$ComputerList += "$_,Sales"

}

$TempFile = New-TemporaryFile
$ComputerList | Out-File $TempFile

PDQInventory.exe CreateCustomField -Name $CustomFieldName -Type $CustomFieldType 
PDQInventory.exe ImportCustomFields -FileName $TempFile -ComputerColumn "ComputerName" -CustomFields "$CustomFieldName=$CustomFieldName" -AllowOverwrite

 

0

Comments

2 comments
Date Votes
  • Hi Tim,
    I am no powershell expert, BUT if you join the PDQ Discord, you will get some help there within hours. you don't have to wait that long. 😁

    https://discord.gg/MxamNxDK

    0
  • If you have a .csv that has your computername and your custom fields (purchase year, eol), you should be able to import those. Is there a particular part that you are stuck on?

    0