Concept Flow - New-Item for creation
Start
Run New-Item cmdlet
Check if path exists
Create new item
Confirm creation
End
The flow shows how New-Item checks if the path exists, creates the item if not, and confirms creation.
New-Item -Path './testfile.txt' -ItemType File| Step | Action | Check | Result | Output |
|---|---|---|---|---|
| 1 | Run New-Item with path './testfile.txt' and type File | Does './testfile.txt' exist? | No | Proceed to create file |
| 2 | Create new file './testfile.txt' | N/A | Success | File created at './testfile.txt' |
| 3 | Confirm creation | Check file exists | Yes | Output object with file info |
| 4 | End | N/A | N/A | New-Item command completes successfully |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | Final |
|---|---|---|---|---|---|
| Path | null | './testfile.txt' | './testfile.txt' | './testfile.txt' | './testfile.txt' |
| Exists | null | False | True | True | True |
| ItemType | null | File | File | File | File |
| Output | null | null | File created | File info object | File info object |
New-Item creates files or folders. Syntax: New-Item -Path <path> -ItemType <File|Directory> Checks if path exists; errors if it does. Creates the item if not present. Outputs an object representing the new item.