Link to home
Start Free TrialLog in
Avatar of GreshAssoc
GreshAssocFlag for United States of America

asked on

Powershell script against list of computers

I want to run a script against a list of computers in order to remove some shortcuts from the public desktops.  question is two fold- top set is win7 bottom is XP.  are both of those correct?  I could not determine the working "public" variable for XP.

second is how do write this to pull from a text file with a list of computer names?

Remove-Item -Path "$env:public\Desktop\Microsoft Access 2010.lnk"
Remove-Item -Path "$env:public\Desktop\Microsoft Excel 2010.lnk"
Remove-Item -Path "$env:public\Desktop\Microsoft Outlook 2010.lnk"
Remove-Item -Path "$env:public\Desktop\Microsoft Word 2010.lnk"
Remove-Item -Path "$env:public\Desktop\adobe reader XI.lnk"

Remove-Item -Path "c:\all users\Desktop\Microsoft Access 2010.lnk"
Remove-Item -Path "c:\all users\Desktop\Microsoft Excel 2010.lnk"
Remove-Item -Path "c:\all users\Desktop\Microsoft Outlook 2010.lnk"
Remove-Item -Path "c:\all users\Desktop\Microsoft Word 2010.lnk"
Remove-Item -Path "c:\all users\Desktop\adobe reader XI.lnk"
ASKER CERTIFIED SOLUTION
Avatar of sirbounty
sirbounty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GreshAssoc

ASKER

awesome, so that seems to work well. now what if I wanted to remove an all user start menu program too?  do I just add in those paths too?
else {
$path = "\\$pc\c$\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office"
Everything beneath that path?  If it contains subfolders, you'll need to include the -recurse parameter
No subfolders there. Would only be the office programs lnk's again. Idea is to get them of the desktop and the programs menu
In that case, I think you can just perform a remove-item and specify *.lnk for the files, using the -recurse parameter.  That will remove and and all shortcuts underneath that path...
Glad I could help - thanks for the grade. :^)