[英]Output all gpo where name like blabla to a file
I'm trying to create a script and a part of it should go to the domain, get all the GPO which names start with "MSAVS-" output that to a file and then in some other part of the script read it.我正在尝试创建一个脚本,它的一部分应该 go 到域,获取名称以“MSAVS-” output 开头的所有 GPO 到一个文件,然后在脚本的其他部分读取它。 problem is, when i do this code:
问题是,当我执行此代码时:
Get-Gpo - all | Where-Object {$._DisplayName - like "MSAVS-*"} | Select-Object
DisplayName | Output-File test.txt
I get the result like this:我得到这样的结果:
blank line空行
DisplayName显示名称
"-----------" “-----------”
blank line空行
MSAVS-blabla1 MSAVS-blabla1
MSAVS-blabla2 MSAVS-blabla2
MSAVS-blabla3 MSAVS-blabla3
etc.. ETC..
I dont want any blank lines, DisplayName and ------- lines I want to get only the names of the GPOs我不想要任何空行、DisplayName 和 ------- 行我只想获取 GPO 的名称
Thanks谢谢
Use Select-Object -ExpandProperty <String>
for this:为此使用
Select-Object -ExpandProperty <String>
:
Get-Gpo -All | Where-Object { $._DisplayName -like "MSAVS-*" } | Select-Object -ExpandPoperty "DisplayName" | Output-File test.txt
-ExpandProperty
- Specifies a property to select, and indicates that an attempt should be made to expand that property: -ExpandProperty
- 将属性指定为 select,并指示应尝试扩展该属性:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.