通常,该脚本旨在搜索Windows上运行的所有虚拟机。
我想找到所有特定的文本文件,正是OSType =“ Win ...”。我的问题是我不知道如何使它查找包含OSType =“ Win ...”的单词。问题是它在文件中写有“”。这是我的代码:
Get-ChildItem -Path C:\Users\*vbox -recurse | Select-String -Pattern 'OSType="Windows7_64"' -List | Select Path | Out-File -FilePath C:\Users\Public\ProcessKurdeExecuted.txt
使用*或%不起作用
...Select-String -Pattern 'OSType="Windows*"'...
...Select-String -Pattern 'OSType="Windows%"'...
您应该尝试
...Select-String -Pattern 'OSType="Windows.*"'...
我找到了解决方案:
$OSType = 'OSType="Windows*'
Get-ChildItem -Path C:\Users\*vbox -recurse | Select-String -Pattern $OSType -List | Select Path | Out-File -FilePath C:\Users\Public\ProcessKurdeExecuted.txt