找到 463 篇文章 適用於 PowerShell

如何在 PowerShell 中控制 Get-ChildItem 中的遞迴?

Chirag Nagrekar
更新於 2020年1月23日 07:37:03

1K+ 次檢視

當 –Depth 引數與 Get-ChildItem 一起使用時,它控制顯示子資料夾及其內容的遞迴。例如,如果 –Depth 引數設定為 1,則它將僅顯示父資料夾和直接子資料夾的內容,而不是子資料夾的子資料夾。命令當您指定 –Depth 引數時,無需新增 –Recursion 引數。它會自動設定深度級別。Get-ChildItem D:\Temp\ -Depth 1輸出PS C:\WINDOWS\system32> Get-ChildItem D:\Temp\ -Depth 1     Directory: D:\Temp Mode                LastWriteTime         Length Name ----             ... 閱讀更多

如何在 PowerShell 中使用 Get-ChildItem 的 -recursive 引數?

Chirag Nagrekar
更新於 2020年1月23日 07:33:19

974 次檢視

要顯示包括檔案和資料夾在內的子資料夾的內容,使用 -Recurse 引數。命令Get-ChildItem -Path D:\Temp -Recurse-Recurse 引數不會顯示隱藏的檔案和資料夾。輸出Directory: D:\Temp Mode                LastWriteTime         Length Name ----                -------------         ------ ---- d-----       13-12-2019     09:52                GPO_backup d-----       24-11-2018     11:31                LGPO -a----       07-05-2018     23:00     ... 閱讀更多

如何使用 PowerShell 中的 Get-ChildItem 列出子資料夾內容?

Chirag Nagrekar
更新於 2020年1月23日 07:30:49

7K+ 次檢視

要顯示包括檔案和資料夾在內的子資料夾的內容,使用 -Recurse 引數。命令Get-ChildItem -Path D:\Temp -Recurse-Recurse 引數不會顯示隱藏的檔案和資料夾。輸出Directory: D:\Temp Mode                LastWriteTime         Length Name ----                -------------         ------ ---- d-----       13-12-2019     09:52                GPO_backup d-----       24-11-2018     11:31                LGPO -a----       07-05-2018     23:00     ... 閱讀更多

如何在 PowerShell 中列出目錄內容?

Chirag Nagrekar
更新於 2020年1月22日 12:42:10

36K+ 次檢視

要顯示目錄內容,使用 Get-ChildItem cmdlet。您需要提供目錄的路徑,或者如果您在同一目錄中,則只需直接使用 Get-ChildItem。在下面的示例中,我們需要顯示 D:\temp 目錄的內容。當 Get-ChildItem 命令在該目錄之外執行時,應提供目錄的路徑。這稱為絕對路徑。PS C:\> Get-ChildItem D:\Temp\命令當此命令直接在目錄中執行時,只需執行此命令。這稱為相對路徑。PS D:\Temp> Get-ChildItem 輸出Directory: D:\Temp Mode       ... 閱讀更多

如何在 PowerShell 中使用 Get-ChildItem 檢索特定檔案的資訊?

Chirag Nagrekar
更新於 2020年1月22日 12:40:58

2K+ 次檢視

當專案(檔案)路徑提供給 Get-ChildItem cmdlet 時,它會提取檔案資訊,如名稱、上次寫入時間、大小等。示例Get-ChildItem -Path D:\Temp\style.css輸出Directory: D:\Temp Mode                LastWriteTime         Length Name ----                -------------         ------ ---- -a----       08-12-2017     10:16            393 style.css命令要獲取檔案的完整屬性,則需要使用 fl *(Format-List *)管道命令。Get-ChildItem -Path D:\Temp\style.css | fl * 輸出PSPath            : Microsoft.PowerShell.Core\FileSystem::D:\Temp\style.css ... 閱讀更多

PowerShell 中的 Get-ChildItem 支援哪些引數?

Chirag Nagrekar
更新於 2020年1月22日 12:39:08

260 次檢視

以下是 Get-ChildItems 支援的引數。Get-ChildItem[[-Path] ] [[-Filter] ] [-Include ] [-Exclude ] [-Recurse] [-Depth ] [-Force] [-Name] [-Attributes ] [-FollowSymlink] [-Directory] [-File] [-Hidden] [-ReadOnly] [-System] []

PowerShell 中的 Get-ChildItem 支援哪些方法?

Chirag Nagrekar
更新於 2020年1月22日 12:44:39

350 次檢視

有一些方法或函式可用於目錄和檔案操作。目錄方法。TypeName: System.IO.DirectoryInfo Name                      MemberType ----                      ---------- Create                    Method CreateObjRef              Method CreateSubdirectory      Method Delete                    Method EnumerateDirectories      Method EnumerateFiles            Method EnumerateFileSystemInfos  Method Equals                    Method ... 閱讀更多

PowerShell 中的 Get-ChildItem 支援哪些屬性?

Chirag Nagrekar
更新於 2020年1月22日 12:37:46

3K+ 次檢視

當您將引數 Get-Member(別名 gm)透過管道傳遞並篩選出屬性時,將顯示兩種不同的屬性。一個是檔案,另一個是資料夾。Get-ChildItem 屬性命令Get-ChildItem | gm | where{$_.Membertype -eq "Property"}輸出** 目錄的屬性 TypeName: System.IO.DirectoryInfo Name              MemberType Definition ----              ---------- ---------- Attributes        Property   System.IO.FileAttributes Attributes {get;set;} CreationTime      Property   datetime CreationTime {get;set;} CreationTimeUtc   Property   datetime CreationTimeUtc {get;set;} Exists            Property   bool Exists {get;} Extension ... 閱讀更多

PowerShell 中的 Get-ChildItem cmdlet 是什麼?

Chirag Nagrekar
更新於 2020年1月22日 12:30:53

980 次檢視

PowerShell 中的 Get-ChildItem(別名:dir)用於獲取容器內的專案。該容器可以是資料夾、登錄檔或證書儲存。您可以從一個或多個指定位置檢索專案。此命令的工作方式類似於命令提示符中的 dir,但 PowerShell 提供了一種更現代的方式來提取資料。

如何在 PowerShell 中執行 Stop-Process 命令後檢查程序是否已從系統退出?

Chirag Nagrekar
更新於 2020年1月22日 12:30:25

828 次檢視

在使用 PowerShell 中的 Stop-Process 命令終止程序後,您可以使用 HasExited 函式確定該程序是否真的已從系統中終止。例如,我們將終止記事本程序並檢查記事本程序是否仍然存在於系統中:$notepad = Get-Process notepad | Stop-Process if($notepad.HasExited){"程序已終止"} else{"程序仍在執行"}

廣告

© . All rights reserved.