Hi, i’m a begginer with powershell
I want to make a script to delete all files from a repertoire called mydocuments without touching some other shild files, for exemple :
if i have my document that have :
test1.txt
test2.csv
test.mp3
test4.doc …
a file with name MYWORk
i want to delete all the file in mydocument without touching the file call MYWORK.
get-childitem -path "FilePath" -Recurse -ne "MYWORk" | remove-item -Force
-ne For Not equal
Is not a helpful description. I’m sure you’ve got an error message. Please always post the complete error message. Error messages are important as they usually tell you what’s wrong.
Regardless of that - wheny oupoast code, error messages, console output or sample data please format it as code using the preformatted text button ( </> ),
Thanks in advance.
And … finally … when you carefully (re-)read the complete help for the cmdlet Get-ChildItem you will see there is no paramter -ne but -Exclude !!!