- PowerShell 教程
- PowerShell - 主頁
- PowerShell - 概述
- PowerShell - 環境設定
- PowerShell - Cmdlet
- PowerShell - 檔案和資料夾
- PowerShell - 日期和計時器
- PowerShell - 檔案輸入/輸出
- PowerShell - 高階 Cmdlet
- PowerShell - 指令碼
- PowerShell - 特殊變數
- PowerShell - 運算子
- PowerShell - 迴圈
- PowerShell - 條件
- PowerShell - 陣列
- PowerShell - 雜湊表
- PowerShell - 正則表示式
- PowerShell - 反引號
- PowerShell - 括號
- PowerShell - 別名
- PowerShell 有用資源
- PowerShell - 快速指南
- PowerShell - 有用資源
- PowerShell - 討論
Powershell - Get-ChildItem Cmdlet
Cmdlet
Get-ChildItem cmdlet 可用於獲取一個或多個特定位置中的專案或子專案。
在以下示例中,我們將看到 Get-ChildItem cmdlet 的實際應用。
示例 1
在此示例中,我們在 D:\temp\test 中有一個名為 test.txt 的檔案,其內容為 "Welcome to TutorialsPoint.Com",而在 D:\temp\test 中有一個名為 test1.txt 的檔案,其內容為 "Hello World!" 和 "Welcome to TutorialsPoint.Com" 這兩行內容。
在變數中獲取檔案詳細資訊。
$A = Get-ChildItem D:\temp\test\*.txt
使用 Format-Wide cmdlet 獲取檔案詳細資訊。
Format-Wide -InputObject $A
輸出
您可以在 PowerShell 控制檯中看到以下輸出。
Directory: D:\temp\test test.txt test1.txt
示例 2
獲取當前目錄中專案的名稱。
在 PowerShell ISE 控制檯中鍵入以下命令
Get-ChildItem -Name
輸出
您可以在 PowerShell 控制檯中看到以下輸出,假定您正在考慮 D:\temp\Test 目錄。
test.csv test.txt test.xml test1.txt
powershell_advanced_cmdlets.htm
廣告