GreshAssoc
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\Micro soft Access 2010.lnk"
Remove-Item -Path "$env:public\Desktop\Micro soft Excel 2010.lnk"
Remove-Item -Path "$env:public\Desktop\Micro soft Outlook 2010.lnk"
Remove-Item -Path "$env:public\Desktop\Micro soft 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"
second is how do write this to pull from a text file with a list of computer names?
Remove-Item -Path "$env:public\Desktop\Micro
Remove-Item -Path "$env:public\Desktop\Micro
Remove-Item -Path "$env:public\Desktop\Micro
Remove-Item -Path "$env:public\Desktop\Micro
Remove-Item -Path "$env:public\Desktop\adobe
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Everything beneath that path? If it contains subfolders, you'll need to include the -recurse parameter
ASKER
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. :^)
ASKER
else {
$path = "\\$pc\c$\ProgramData\Micr