我有以下代码:输出网络共享位置到控制台用写主机
$exclude = 'Remote Admin', 'Remote IPC', 'Default share'
$shared = Get-WmiObject Win32_Share |
Where-Object { $exclude -notcontains $_.Description } |
Select-Object -Expand Path
$FilesToSearch = Get-ChildItem $shared -Filter '*_HELP_instructions*' -Recurse -ErrorAction SilentlyContinue
If($FilesToSearch -ne $null)
{
Write-Host "System Infected!"
exit 2015
}
else
{
Write-Host "System Clear!"
exit 0
}
本质上是通过一个本地服务器的任何文件上的所有共享扫描与_HELP_instructions的文件名。
如果找到与此名称匹配的文件,则会输出“System Infected!”到控制台并用特定的代码退出脚本。
我想要做的是实际详细的共享位置感染和输出到控制台。输出看起来像“网络共享E:\数据\客户端被感染!”。
请问这可以实现吗?
非常感谢
'$ FilesToSearch'如果不为空应该包含文件。您可以输出该变量,该变量应该是受感染文件路径的数组。 – Nkosi
嗨Nkosi - 所以代码行将是: { 写主机“网络共享”$ FilesToSearch“被感染!” 退出2015 } 会这样吗? –