February 2019
Intermediate to advanced
626 pages
15h 51m
English
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 the removal of files with Hidden or System attributes. The error that's generated when attempting to delete a Hidden file is shown in the following code:
PS> Set-Location $env:TEMPPS> New-Item IMadeThisUp.txt -ForcePS> Set-ItemProperty .\IMadeThisUp.txt –Name Attributes –Value HiddenPS> Remove-Item IMadeThisUp.txtRemove-Item : Cannot remove item C:\Users\whoami\AppData\Local\Temp\IMadeThisUp.txt: You do not have sufficient access rights to perform this operation.At line:1 char:1+ Remove-Item .\IMadeThisUp.txt+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ...
Read now
Unlock full access