1.必須先安裝python
2.安裝虛擬環境
pip install virtualenv
1.必須先安裝python
2.安裝虛擬環境
pip install virtualenv
To export:
docker container export <container_id> -o <image_name>.tar
To import
docker image import <image_name>.tar <custom_image_name>
Please note in Windows use -o instead of >. The export done with > works with Linux/MAC only.
1.Get-NetAdapter | Select-Object -Property Name, MacAddress
# 取得應用程式事件檢視器中等級為錯誤的最近10筆事件
$events = Get-EventLog -LogName Application -EntryType Error -Newest 10
# 顯示事件資訊
foreach ($event in $events) {
Write-Host "事件時間: $($event.TimeGenerated)"
Write-Host "事件ID: $($event.EventID)"
Write-Host "消息: $($event.Message)"
Write-Host "----------------------"
}
------------------------------------------------------------------------------------------------
Get-WinEvent -FilterHashtable @{
"LogName" = "Application"
"Level" = 2 # 2 代表錯誤,可以根據需要調整
} | Select-Object * -First 10
計算目錄下所有子目錄的總數
find /path/to/your/directory -mindepth 1 -maxdepth 1 -type d | wc -l
------------------------------------------------------------------------------------
列出目錄下所有子目錄
find /path/to/your/directory -mindepth 1 -maxdepth 1 -type d -exec sh -c 'echo "{}";' \;
--------------------------------------------------------------------------------------
計算目錄下所有子目錄的總數並列出目錄下所有子目錄
find /path/to/your/directory -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | tee /dev/tty | wc -l
/path/to/your/directory 改為你要的目錄
UTF-8的Code Page是65001,先chcp 65001,如果 CodePage 的設定要持久的話,
要在 [HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\] 底下新增一個字串 Autorun,裡面填 "chcp 65001>nul"
一、 您可以在
PowerShell
中使用
New-Alias
或
Set-Alias
命令创建别名。要使别名永久保存,您需要将此命令写入
Windows
PowerShell profile 文件123。以下是一些步驟:
打開
PowerShell
并輸入
$profile
命令,以查找
profile
文件的位置。
如果文件不存在,請使用
New-Item
-ItemType File -Force $profile
命令創建文件。
打開文件并添加您的別名。例如,如果您想要將
Get-ChildItem
命令的別名設置為
ls,則可以添加以下行:New-Alias
ls Get-ChildItem。
保存文件并關閉它。
這樣,您的別名將在 PowerShell 会话之间保持不变,即使您关闭计算机或重启主机123。
希望這可以幫助您!
二、在PowerShell中自定義的Alias最理想的情況下是應該被永久保存。這可以通過兩種方式實現:一種是修改PowerShell的配置文件,另一種是使用腳本文件。
修改 PowerShell 配置文件:
在Windows上,PowerShell的配置文件位於C:\Users\<username>\Documents\Microsoft\WindowsPowerShell\profile.ps1。在macOS上,它位於~/.config/powershell/目錄中。您可以編輯這個文件來添加或更改您的Alias。例如,要永久保存一個名為“MyAlias”的新Alias,你可以在該文件中添加以下代碼:
function MyAlias {
Write-Output "This is my custom alias."
}
New-Alias -Name MyAlias -Definition (Get-Command Get-Date).Definition -Force
這將創建一個名為“MyAlias”的新命令,并使用 Get-Date 命令的定義。在 macOS 上,您需要在終端中運行 chmod +x ~/.config/powershell/profile.ps1 來將 profile.ps1 文件設置為可執行。
使用腳本文件:
你也可以創建一個名為.powershell_profile.ps1的文件并將自定義Alias添加到其中。這個文件可以位於您的home目錄下,例如 ~/.powershell_profile.ps1 在macOS上或C:\Users\<username>\Documents\PowerShell\Microsoft.PowerShell_profile.ps1 在Windows上。這個文件是一個可執行腳本,每次打開PowerShell時都會自動運行。
例如:創建或編輯 .powershell_profile.ps1 (macOS) 或 Microsoft.PowerShell_profile.ps1 (Windows) 文件并添加以下代碼:
function MyAlias {
Write-Output "This is my custom alias."
}
New-Alias -Name MyAlias -Definition (Get-Command Get-Date).Definition -Force
然后,你可以在PowerShell中運行 source ~/.powershell_profile.ps1 (macOS) 或 & $PROFILE (Windows) 來加載這個腳本文件并啟用自定義Alias。
無論釆用哪種方法,您的自定義Alias將被永久保存,不會因為主機重啟或關機而消失。