[英]How do i Filter the DHCP Lease information that i export
I just wrote a powershell script that will export dhcp lease information but i want to export specific information like export only IP and mac addresses in the dhcp. 我刚刚编写了一个Powershell脚本,该脚本将导出dhcp租约信息,但我想导出特定的信息,例如仅导出dhcp中的IP和mac地址。 Instead of exporting every lease information. 而不是导出每个租赁信息。 The one line of code i have written that exports everything is bellow. 我写的导出所有内容的一行代码如下。
Get-DhcpServerv4Lease -ComputerName "HW2009-11" | Export-Csv -Path ("C:\log\new.csv")
To adress only certain properties of an object, you can use Select-Object
. 要仅处理对象的某些属性,可以使用Select-Object
。 This way you can only choose the ip
and mac-address
like this: 这样,您只能像这样选择ip
和mac-address
:
Get-DhcpServerv4Lease -ComputerName "HW2009-11" | Select-Object -Property IP, mac-address
You can then pipe this to Export-Csv
and it will create a .csv file with only those properties: 然后,您可以将其通过管道传输到Export-Csv
,它将创建仅具有以下属性的.csv文件:
Get-DhcpServerv4Lease -ComputerName "HW2009-11" | Select-Object -Property IP, mac-address | Export-Csv -Path "C:\log\new.csv"
If you don't know the specific properties of an object, you can just pipe the command to Get-Member
: 如果您不知道对象的特定属性,则可以将命令通过管道传递给Get-Member
:
Get-DhcpServerv4Lease | Get-Member
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.