找到 463 篇文章 關於 PowerShell

如何使用 PowerShell 更改控制檯大小?

Chirag Nagrekar
更新於 2020年1月23日 08:05:01

1K+ 次瀏覽

您可以使用 GUI 和 CLI 兩種方式更改 PowerShell 控制檯的大小。使用 GUI - 使用 CLI - 要更改控制檯的寬度,`$host.UI.RawUI.WindowSize.Width = 150` 要更改控制檯的高度,`$host.UI.RawUI.WindowSize.Height = 60`

如何在 PowerShell 中更改字型的背景顏色?

Chirag Nagrekar
更新於 2020年7月14日 13:16:43

3K+ 次瀏覽

要更改字型的背景顏色,您可以同時使用 GUI 和命令列。使用 GUI - 顏色 → 螢幕背景。CLI - `$host.UI.RawUI.BackgroundColor = "DarkBlue"` 您會注意到文字的背景顏色已更改為深藍色。

如何使用 PowerShell 更改控制檯的前景色或字型顏色?

Chirag Nagrekar
更新於 2020年1月23日 08:03:21

7K+ 次瀏覽

在 PowerShell 中,字型顏色被稱為前景色。要更改字型顏色,您可以使用控制檯 GUI 屬性“螢幕文字”。共有 16 種顏色可供選擇,您也可以更改 RGB 屬性。命令要使用指令碼更改顏色,請使用以下命令:`$Host.UI.RawUI.ForegroundColor = "Yellow"` 輸出您可以看到前景色立即發生變化。

如何使用 PowerShell 命令更改控制檯標題?

Chirag Nagrekar
更新於 2020年1月23日 08:02:29

6K+ 次瀏覽

出於各種原因,您需要更改 PowerShell 控制檯的標題。例如,將標題描述為指令碼。例如,系統資訊或服務資訊。要更改 PowerShell 控制檯標題,請使用 RawUI 中的“WindowTitle”屬性。這只是一個臨時更改。當您關閉控制檯並再次開啟它時,標題將設定為預設值。`$host.UI.RawUI.WindowTitle = "System Information"` 現在 PowerShell 控制檯的標題已更改為“System Information”。您還可以為此引數提供變數值。`$Title = "System Information" $host.UI.RawUI.WindowTitle = $Title`

如何檢查 Windows PowerShell 控制檯的屬性?

Chirag Nagrekar
更新於 2020年1月23日 08:01:45

786 次瀏覽

您可以透過兩種方式檢查 PowerShell 控制檯屬性。第一種方法是右鍵單擊標題欄並開啟屬性。例如,命令您可以找到各種屬性。例如視窗大小、游標大小、字型大小、字型顏色等。但是,您可以使用 $host UI 配置中的 RawUI 屬性在指令碼執行時動態更改屬性。您可以使用以下命令檢視控制檯的屬性,這是第二種方法:`$host.UI.RawUI` 輸出ForegroundColor : DarkYellow BackgroundColor : Black CursorPosition : 0,6 WindowPosition : 0,0 CursorSize : 25 BufferSize : 120,3000 WindowSize : 120,43 MaxWindowSize : 120,44 MaxPhysicalWindowSize : 151,44 KeyAvailable : False WindowTitle : Administrator: Windows PowerShell

如何使用 PowerShell 中的 Get-ChildItem 獲取僅檔案而不獲取資料夾?

Chirag Nagrekar
更新於 2020年1月23日 08:00:41

8K+ 次瀏覽

要僅獲取檔案,您需要在 Directory 屬性引數中使用 NOT 運算子。示例`Get-ChildItem D:\Temp\ -Attributes !Directory` 輸出`irectory: D:\Temp Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 07-05-2018 23:00 301 cars.xml -a---- 29-12-2017 15:16 4526 healthcheck.htm -a---- 29-12-2017 15:16 4526 healthcheck1.htm -ar--- 13-01-2020 ... 閱讀更多

如何在 PowerShell 中的 Get-ChildItem 中僅獲取資料夾而不獲取檔案?

Chirag Nagrekar
更新於 2020年1月23日 08:02:54

1K+ 次瀏覽

要僅獲取不包含檔案的資料夾,我們需要將 –Attribute 引數與 Directory 屬性一起使用。命令`Get-ChildItem D:\Temp\ -Attributes Directory` 輸出`Directory: D:\Temp Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 13-12-2019 09:52 GPO_backup d----- 24-11-2018 11:31 LGPO` 同樣,您可以組合不同的操作。要僅獲取系統目錄,請使用以下命令:`Get-ChildItem D:\Temp\ -Attributes Directory –System -Recurse` 要獲取隱藏的系統目錄:`Get-ChildItem D:\Temp\ -Attributes Directory -Recurse –System -Hidden` 要獲取只讀的系統目錄:`Get-ChildItem D:\Temp\ -Attributes Directory -Recurse –System -Readonly`

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

Chirag Nagrekar
更新於 2020年1月23日 07:54:55

354 次瀏覽

PowerShell 中的 Get-ChildItem 支援以下屬性引數。`Get-ChildItem` 別名 參考: --------------------------------- `Get-ChildItem` dir Directory d, ad File af Hidden h, ah ReadOnly ar System as

如何使用 PowerShell 中的 Get-ChildItem 獲取系統檔案?

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

1K+ 次瀏覽

系統檔案是作業系統檔案,預設情況下使用 Get-ChildItem 無法看到。要獲取系統檔案,您需要使用 –System 引數。示例例如,以下命令將為您提供 C:\Windows\System32 下的系統檔案和資料夾。`PS C:\WINDOWS\system32> Get-ChildItem -System` 輸出`Directory: C:\WINDOWS\system32 Mode LastWriteTime Length Name ---- ------------- ------ ---- d---s- 25-12-2019 01:14 AppV d---s- 19-03-2019 10:22 ... 閱讀更多

如何使用 PowerShell 中的 Get-ChildItem 獲取只讀檔案?

Chirag Nagrekar
更新於 2020年1月23日 07:53:04

1K+ 次瀏覽

要在 PowerShell 中使用 Get-ChildItem 獲取只讀檔案,您需要使用 –Readonly 檔案。只讀檔案具有屬性“r”。在下面的示例中,您可以檢查檔案的屬性。`Get-ChildItem D:\Temp\ -ReadOnly` 輸出`PS C:\WINDOWS\system32> Get-ChildItem D:\Temp\* -ReadOnly Directory: D:\Temp Mode LastWriteTime Length Name ---- ------------- ------ ---- -ar--- 13-01-2020 18:19 0 Readonlyfile.txt` 您可以檢查 Mode 屬性中的只讀屬性值。

廣告
© . All rights reserved.