Concept Flow - Remove-Item
Start
Specify Path
Check if Item Exists
Remove Item
Confirm Removal
End
The flow starts by specifying the item path, checks if it exists, removes it if found, then confirms removal or exits if not found.
Remove-Item -Path './testfile.txt' Write-Output 'File removed.'
| Step | Action | Evaluation | Result |
|---|---|---|---|
| 1 | Check if './testfile.txt' exists | File exists | Proceed to remove |
| 2 | Remove './testfile.txt' | File deleted | File no longer exists |
| 3 | Write output | Output string | 'File removed.' printed |
| 4 | End | No more commands | Script finishes |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | Final |
|---|---|---|---|---|---|
| Path | './testfile.txt' | './testfile.txt' | Removed | Removed | Removed |
| Output | None | None | None | 'File removed.' | 'File removed.' |
Remove-Item removes files or folders by path. If the item exists, it deletes it. Use -Recurse to delete folders with contents. Errors occur if item not found unless handled. Commonly used to clean files in scripts.