创建新项的操作方式在所有 Windows PowerShell 提供程序上都相同。 如果某个 Windows PowerShell 提供程序具有多个类型的项(例如,用于区分目录和文件的 FileSystem Windows PowerShell 提供程序),则需要指定项类型。
以下命令可创建一个新文件夹 C:\temp\New Folder

New-Item -Path 'C:\temp\New Folder' -ItemType Directory

以下命令可创建新的空文件 C:\temp\New Folder\file.txt

New-Item -Path 'C:\temp\New Folder\file.txt' -ItemType File