PS
Powershell Tutorial Online

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



Powershell Tutorial is optimized for learning technology step by step. Examples might be simplified to improve reading and basic understanding. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Send your suggestions or feedback to [email protected]
Copyright © 2014 by Powershell Tutorial. All Rights Reserved.