Will executing New-Item command deletes the contents/folders if it exists already.
The script is New-Item “$HOME\Desktop” -Name “foldername” -ItemType “directory” -Force
Will executing New-Item command deletes the contents/folders if it exists already.
The script is New-Item “$HOME\Desktop” -Name “foldername” -ItemType “directory” -Force
hi Renjith,
The documentation for this command talks about this:
New-Item Documentation
In short - yes it will overwrite the file if it already exists, using the -Force parameter does this.
What you might want to do is have some error handling around if the file already exits with Test-Path and then decide from that output if you use New-Item or Add-Content
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.