The Force parameter has a different purpose.
With the Force parameter, New-Item will overwrite any existing file with the same path. When used with Remove-Item, the Force parameter allows removal of files with Hidden or System attributes. The error generated when attempting to delete a Hidden file is shown in the following code:
PS> Set-Location $env:TEMP
New-Item IMadeThisUp.txt -Force
Set-ItemProperty .IMadeThisUp.txt –Name Attributes –Value Hidden
Remove-Item IMadeThisUp.txt
Remove-Item : Cannot remove item C:UserswhoamiAppDataLocalTempIMadeThisUp.txt: You do not have sufficient access rights to perform this operation.
At line:1 char:1
+ Remove-Item .IMadeThisUp.txt
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (C:Usersuktpcd...IMadeThisUp.txt:FileInfo) [Remove-Item], IOException
+ FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
Adding the Force parameter allows the operation to continue without the error message:
PS> Set-Location $env:TEMP
New-Item IMadeThisUp.txt -Force
Set-ItemProperty .IMadeThisUp.txt –Name Attributes –Value Hidden
Remove-Item IMadeThisUp.txt -Force