New-Item 用于创建文件和文件夹.
New-Item xxxx -type directory
新建的目录是没有文件的。
进入目录是
cd xxx
或者Set-Location xxxx
# 桌面路径
$desktop = [System.Environment]::GetFolderPath('Desktop')
$path = Join-Path $desktop -ChildPath 'newFolder'
# 创建目录
if (-not (Test-Path $path))
{
New-Item $path -ItemType "directory"
}
# 列出文件
Get-ChildItem $path -Filter "*.txt" -File