2025-04-23

OpenSSL 憑證處理遇到 unsupported encryption algorithm

openssl pkcs12 -in "www.Contoso.com.pfx"
=> unsupported encryption algorithm (RC2-40-CBC)

=> openssl pkcs12 -in "$1" -legacy

參考資料:
https://github.com/openssl/openssl/discussions/23089

Link User to Existed Exchange Online Mailbox

Powershell Exchange Online

Get-Mailbox UserName | fl ExchangeGuid    #取得 ExchangeGuid

PowerShell On-Premises

Enable-RemoteMailbox UserName -RemoteRoutingAddress  UserName@YourDomain.mail.onmicrosoft.com
Set-RemoteMailbox UserName -ExchangeGuid <ExchangeGuid from above>

如果是 Shared Mailbox, Enable-RemoteMailbox 指令加上 -Shared 參數

參考資料:
https://www.itpromentor.com/link-aduser-365/


2025-04-18

以 ffmpeg 批次降低影片 bitrate

運動攝影機錄影擋預設流量 (bitrate) 很高,但其實我覺得看不太出來高低流量畫質的差異
所以根據網路查的一些建議用 ffmpeg 批次處理降低流量
先用 
ffprobe.exe 取得影片屬性,再根據影片屬性進行處理

以下 Powershell 中,VideoRotation 是影片方向的資訊,在降低流量的處理中實際上不需要
這裡只是當作筆記用,未來有需要的時候才找得到
 (找很久才找到這個語法)

#設定要降低的 bitrate 值 Start
$ProcessMethod = @();
$ProcessMethod += New-Object -TypeName PSObject -Property @{
     Width = 2688;
     FrameRate = 30;
     BitRate = 16;
};
$ProcessMethod += New-Object -TypeName PSObject -Property @{
     Width = 2688;
     FrameRate = 60;
     BitRate = 24;
};
$ProcessMethod += New-Object -TypeName PSObject -Property @{
     Width = 3840;
     FrameRate = 30;
     BitRate = 45;
};
$ProcessMethod += New-Object -TypeName PSObject -Property @{
     Width = 3840;
     FrameRate = 60;
     BitRate = 55;
};
$ProcessMethod += New-Object -TypeName PSObject -Property @{
     Width = 3840;
     FrameRate = 120;
     BitRate = 65;
};
#設定要降低的 bitrate 值End

360 全景影片加入 Metadata Tag

全景影片用 VLC 等媒體播放軟體播放時若預設不以全景模式播放代表缺少 Metadata Tag
解決辦法如下,如果檔案量少,可以直接用 GUI 程式處理,檔案多的話跑批次比較省事

GUI & Source: google spatial-media
https://github.com/google/spatial-media/releases

Command 需要 python 2.7 (新版不行)
根據影片類型可能要加入 StereoMode 參數,請自行參考程式說明
先轉轉看確認參數再跑批次

Set-Location -Path "D:\Software\spatial-media-2.1\";
$Files = (Get-ChildItem -Path 'D:\Video' -File)
foreach ($File in $Files) {
& D:\Python27\python.exe spatialmedia -i $File.FullName ($File.FullName -Replace $File.BaseName,($File.BaseName + '_360 Tag Added'));
#if (($File.FullName -Replace $File.BaseName,($File.BaseName + '_360 Tag Added')) -eq $True) {
# remove-item -path $File.FullName -force;
#};

};

技術細節可 Google 關鍵字: Inject 360 Metadata

Shrink MS SQL LDF File

ALTER DATABASE [DBName] SET RECOVERY SIMPLE;
dbcc shrinkfile(DBName_log, 1);
ALTER DATABASE [DBName] SET RECOVERY FULL;

參考資料:
https://sdwh.dev/posts/2021/03/SQL-Server-LDF-Truncate-Shrink/

Windows TCP Port Forwarding

古時候 (2000年左右) Windows 98 時代對於網路不太熟悉
有接觸到一個小程式叫做 PortMagicV130 (網路魔術師)
可以做到 Port Forwarding 的功能,也就是將電腦作為跳板的用途

現在只要下指令就可以做到了:
netsh interface portproxy add v4tov4 listenport=80 listenaddress=192.168.1.10 connectport=80 connectaddress=1.1.1.1
紅色的部分 是本機電腦要聽的 Port 與  IP
綠色的部分 是要轉去目標的 Port 與  IP

用這個指令可以查目前的設定:
netsh interface portproxy show all
這樣刪除
netsh interface portproxy delete v4tov4 listenport=80 listenaddress=192.168.1.10

netsh interface portproxy delete listenport=80 listenaddress=192.168.1.10
參考資料:

2025-03-05

廣告、跟蹤、釣魚等過濾用 Public DNS Server

Server 不建議使用

AdGuard DNS(無過濾功能):
94.140.14.140
94.140.14.141

AdGuard DNS(攔截廣告、跟蹤器和釣魚網站)
94.140.14.14
94.140.15.15

AdGuard DNS(攔截廣告、跟蹤器、釣魚網站和成人內容的網站)
94.140.14.15
94.140.15.16

Cloudflare DNS(隱私權保護)
1.1.1.1
1.0.0.1

Cloudflare DNS (阻止惡意程式)
1.1.1.2
1.0.0.2

Cloudflare DNS (阻止惡意軟件及成人內容)
1.1.1.3
1.0.0.3

https://dns.sb/
185.222.222.222
45.11.45.11

2025-03-04

Create Microsoft Entra Application Service Principal for Connect-AzAccount

在 PowerShell 中用帳號密碼進行 Connect-AzAccount 會被罵

WARNING: Authentication with a username and password at the command line is strongly discouraged. Use one of the recommended authentication methods based on your requirements. For additional information, visit https://go.microsoft.com/fwlink/?linkid=2276971.

先用具有適當權限的帳號登入後用以下 Script 建立 Service Principal Application
再到 RBAC 賦予需要的權限

Set-Location -LiteralPath 'C:\Command\AzureConnect';

$AzureEntraTenantId = 'xxxxxxxx-xxxx-xxxx-xx-xxxxxxxxxxxx';
$AzSubscriptionID = 'xxxxxxxx-xxxx-xxxx-xx-xxxxxxxxxxxx';
$ServicePrincipalName = 'PowershellAutomaticProcess';
$CredentailFileName = ('AzConnect_' + $ServicePrincipalName + '.txt')
$CertificateExpired = 100;
#設定密碼 100 年後到期 (預設 1 年),往下找 AddYears 字串那邊可以改

2025-02-20

用 PowerShell 取得電腦資訊、軟體清單等資料

 這支 Powershell Script 蒐集以下資訊並以 JSON 格式存到 Share Folder

LogonServer
Site
UserName
ComputerName
ComputerInfo
DiskInfo
Applications
NetworkInfo
GroupsInfo
LocalUsers

用 GPO 派送,目標 Share Folder 給予 User 建立 Child Object 權限
並給予 Creator Owner 刪除權限

以 User Name + Computer Name 為檔名,後加上日期年月日時分秒
保留最新的 5 個 Report

2025-02-06

Synology Active Backup for Business for Hyper-V VM Failed to Backup #02

繼前一篇  Synology Active Backup for Business for Hyper-V VM Failed to Backup #01
取得 Patch 跳過了 5 個 Snapshots 的問題後

還是備份失敗

於是再用 Support Center App 產生 Active Backup for Business 的 Debug Log 後
在 ActiveBackup\volume1\@ActiveBackup\log\vm.log 中看到

synoabk_vm_backup[6175]: synoabk_vm::[WARNING] hyperv_agent.cpp:1381(6175,139923524343360) [6175]hypervisor_agent/hyperv_agent.cpp:145 {"error_class":"PowerShellException","error_message":"Missing an argument for parameter 'Id'. Specify a parameter of type 'System.Int32[]' and try again.","error_params":{"Activity":"Stop-Process","Category":5,"Reason":"ParameterBindingException","TargetName":"","TargetType":"","error_id":"MissingArgument,Microsoft.PowerShell.Commands.StopProcessCommand"},"success":false}

難道是 Powershell 語法錯誤少帶一個參數?