Powershell Create File

Scenario 1: Folder alrady present like here "c:\test"

Example


# Using PowerShell commnads to create a new file
$Location = "C:\test"
New-Item -Path $Location -Name "FirstCreateFile.txt" -ItemType File

Copy and Try it

Scenario 2: Folder is not there

Example


# Using PowerShell commnads to create a new file if folder is not there
$Location = "C:\test"
New-Item -Path $Location -Name "FirstCreateFile.txt" -ItemType File

Copy and Try it


Scenario 2: Folder is not there with force create folder

Example


# Using PowerShell commnads to create a new file if folder is not there
$Location = "C:\test"
New-Item -Path $Location -Name "FirstCreateFile.txt" -ItemType File
    

Copy and Try it