I need some help with a powershell script to exclude certain folders and files.
I have it written so far that it ignores shortcuts and a folder called data, but when the delete command runs, it also deletes all of the content's of the Data folder on the users desktop.
This is the essential part of what I have
$exclude = ('*.lnk', "*data*")
{Get-ChildItem -Path ([environment]::GetFolderPath("Desktop")) -Exclude $exclude -Recurse | Remove-Item -Force -Recurse}
How can I best achieve what I want, this is to have the script run at each startup, remove all desktop content apart from shortcuts and the Data folder+contents. The contents could be anything from exe to mp3 and I do not want to just exclude MP3 from deletion as I may well want them removed from other folders that have been placed on the desktop.
regards