我想使用两个条件来过滤命令结果。这是我的命令
$list=Get-PnpDevice | Sort-Object -Property Name | Where-Object -Property FriendlyName -like '*touch screen*' | ft Name, InstanceId -AutoSize
下一个过滤器是
and
它们都可以单独工作,但是我想使用-AND
命令加入它们。我尝试将
Get-PnpDevice | Sort-Object -Property Name | Where-Object{
( ConfigurationFlags -NotLike '*DISABLED*') -and
( FriendlyName -like '*touch screen*' ) }| ft Name, InstanceId -AutoSize
用作以下命令,但它不断出现错误
// Handler
public Optional<Response> handle(HandlerInput input) {
//I tried with url.openStream () but it doesn't work
}
// Servlet
public class AlexaServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
PrintWriter out = resp.getWriter();
out.println("Hello Alexa");
out.close();
}
答案 0 :(得分:1)
只需使用$_
中的Where-Object
automatic variable来引用属性名称:
Get-PnpDevice | Sort-Object -Property Name | Where-Object{
( $_.ConfigurationFlags -NotLike '*DISABLED*') -and
( $_.FriendlyName -like '*touch screen*' ) }| ft Name, InstanceId -AutoSize
答案 1 :(得分:1)
您可以将'Where'子句通过管道连接在一起...语法更简单,更易于阅读
Get-PnpDevice | Sort-Object -Property Name | Where ConfigurationFlags -NotLike '*DISABLED*' | Where FriendlyName -like '*touch screen*' | ft Name, InstanceId -AutoSize