Something like this might be what you're looking for:
$dhcpserver = 'srv01','srv07'
$optionids = 3,6
$dhcpserver |
ForEach-Object{
$servername = $_
Get-DHCPServerv4Scope -ComputerName $_ |
ForEach-Object{
$scopeid = $_.ScopeId
Get-DHCPServerv4OptionValue -ComputerName $_ -ScopeID $scopeid -OptionId $optionids |
ForEach-Object{
[PSCustomObject]@{
DHCPServer = $servername
ScopeID = $scopeid
OptionId = $_.OptionId
Name = $_.Name
Value = $_.Value -join ';'
}
}
}
} | Export-Csv c:\junk\scopids.csv -NoTypeInformation