-1

Can you use the command Remove-Item to delete based on the "Company" field - it's one of the fields that windows has and i want to basically delete everything that has one of the following values

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

Is this possible?

Alex Young
  • 25
  • 7
  • It's unclear **what** you want to remove. But in general with PowerShell the short answer is: yes it is possible. –  May 10 '18 at 09:28
  • Well in File Explorer when you right click on the columns and select More you can pick "Company" and it shows more details - does that make sense. [link](http://www.sage.co.uk/images/ask/17213/img3.jpg) – Alex Young May 10 '18 at 09:35
  • https://stackoverflow.com/questions/9420055/enumerate-file-properties-in-powershell#9420165 – gvee May 10 '18 at 09:42
  • `Remove-Item` will remove what you either pipe in or express as paramter. Deleting `.exe` or `.dll` originating from Sage won't remove the installed sofware completely and will leave a lot of folders with other information. I suggest you first see what's installed `get-wmiobject -Class Win32_Product|? Vendor -match 'Sage'|select Name,Version,Vendor|ft -auto` –  May 10 '18 at 09:49

1 Answers1

2
$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

This sould work. Replace $path with folderpath you want to check

Evilcat
  • 388
  • 3
  • 9
  • Not even a `-WhatIf` or `-Confirm` parameter to first check everything works OK? –  May 10 '18 at 11:50