Simple thing that I keep forgetting, how do I add a property (column) to a object in powershell
$result = Get-DHCPServerv4OptionValue -ComputerName 2012-dhcp1 -ScopeID 10.104.0.0 |select *,@{label=”DHCPServer”; Expression= {“2012-dhcp1”}}
# $result = Get-DHCPServerv4OptionValue -ComputerName 2012-dhcp1 -ScopeID 10.104.0.0 |select *,@{label=”DHCPServer”; Expression= {"2012-dhcp1"}} #
the key is the pipe of whatever object you are creating to a select * command, then followed by the “column” expression (the column you want to add) Here is a link to a simple example, I needed to get the list of options per scope to compare one DHCP server scope to another. I use out-gridview a lot as I can copy and paste the results to excel or any app really. Also I can drag and drop the columns and change selection criteria, to filter the results.
Pingback: DHCP - Get a List of Scopes and Scope Options from 2012 R2 DHCP Server | BritV8