首页 > 解决方案 > Powershell - 你能根据公司删除项目吗

问题描述

您可以使用命令 Remove-Item 根据“公司”字段进行删除吗?它是 windows 拥有的字段之一,我想基本上删除具有以下值之一的所有内容

$company = "Sage (UK) Limited","Sage (UK) Ltd","Sage","The Sage Group plc","SAGE Software Ltd"

这可能吗?

标签: powershell

解决方案


$path = 'C:\'
$company = 'Sage (UK) Limited','Sage (UK) Ltd','Sage','The Sage Group plc','SAGE Software Ltd'

Remove-Item (Get-ChildItem $path | Where-Object {$company.Contains($_.VersionInfo.CompanyName)}).FullName

这个灵魂的工作。替换$path为您要检查的文件夹路径


推荐阅读