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 語法錯誤少帶一個參數?

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

備份失敗了,說我的 Snapshot 數量超過 5 個所以不給備

Virtual machine VMName's snapshots have reached the maximum number (5).
You need to delete some snapshots on the device

但實際上根本就一個 Snapshot 也沒有

Synology 用 Support Center App 產生 Debug Log

在使用 Synology NAS 在發生問題時為了查原因
除了系統預設相當簡略的錯誤訊息以外,可以匯出詳細 Log 來 Debug

執行 Support Center App

切換到 Support Services 頁籤

Synology Active Backup for Business for Hyper-V VM List Blank

初次使用 Synology Active Backup for Business 的時候
Hyper-V Server 連線成功,但 VM 列表一片空白

用 Support Center App 產生 Active Backup for Business 的 Debug Log
在 dsm\var\log\synoscgi.log 找到以下錯誤訊息

NAS synoscgi_SYNO.ActiveBackup.Inventory_1_list_node[24340]:
[ERROR] main.cpp:212(24340,139646703461952)
Code: [0]
What: [[24340]hypervisor_agent/hyperv_agent.cpp:145
{"error_class":"PowerShellException","error_message":"std_out: b'[ //VM Information JSON// ]',
std_err:
Get-VM : Hyper-V encountered an error trying to access an object on computer 'HYPER-V-xxxxxx' because the object was 
not found. The object might have been deleted, or you might not have permission to perform the task. Verify that the 
Virtual Machine Management service on the computer is running. If the service is running, try to perform the task 
again by using Run as Administrator.
At line:3 char:1
+ Get-VM| Select Id,Name,MemoryStartup,ProcessorCount,State,Status,Prim ...
+ ~~~~~~
    + CategoryInfo          : ObjectNotFound: (:) [Get-VM], VirtualizationException
    + FullyQualifiedErrorId : ObjectNotFound,Microsoft.HyperV.PowerShell.Commands.GetVM
 
Get-VM : Hyper-V encountered an error trying to access an object on computer 'HYPER-V-xxxxxx' because the object was 
not found. The object might have been deleted, or you might not have permission to perform the task. Verify that the Virtual Machine Management service on the computer is running. If the service is running, try to perform the task again by using Run as Administrator. At line:3 char:1 + Get-VM| Select Id,Name,MemoryStartup,ProcessorCount,State,Status,Prim ... + ~~~~~~ + CategoryInfo : ObjectNotFound: (:) [Get-VM], VirtualizationException + FullyQualifiedErrorId : ObjectNotFound,Microsoft.HyperV.PowerShell.Commands.GetVM, status_code: 1", "error_params":{"error_id":""},"success":false}]

2025-02-03

防止網頁在 Chrome 中被翻譯 Disable Google translate from HTML in Chrome

<!DOCTYPE html>
<html lang="en" class="notranslate" translate="no">
    <head>
        <meta name="google" content="notranslate" />
    </head>
        <body>
        ...
        </body>
</html>

出處: https://stackoverflow.com/questions/12238396/how-to-disable-google-translate-from-html-in-chrome

2025-01-14

Increase SoftEther RADIUS timeout to 60 seconds for 2FA/MFA

Modify the source code and compile it yourself

---------------------------------------------------------------------------------------------

src\Cedar\Radius.h

//#define RADIUS_RETRY_INTERVAL 500 // Retransmission interval
//#define RADIUS_RETRY_TIMEOUT (10 * 1000) // Time-out period

#define RADIUS_RETRY_INTERVAL 60000 // Retransmission interval
#define RADIUS_RETRY_TIMEOUT (60 * 1000) // Time-out period

---------------------------------------------------------------------------------------------

src\Cedar\Cedar.h

2025-01-02

Get All DHCP Lease Info

$DHCPServer = "DHCPServer.Contoso.com";
$DHCPScopes = Get-DhcpServerv4Scope -ComputerName $DHCPServer;
foreach ($Scope in $DHCPScopes) {
Get-DhcpServerv4Lease -ComputerName $DHCPServer -ScopeID $Scope.ScopeId;
};

or

$Global:Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False;
$DHCPData = (Get-DhcpServerv4Scope -ComputerName "DHCPServer.Contoso.com" | Get-DhcpServerv4Lease -ComputerName "DHCPServer.Contoso.com");
[System.IO.File]::WriteAllLines('C:\DHCP.json', ($DHCPData | ConvertTo-Json -Depth 100 -Compress), $Global:Utf8NoBomEncoding);

--##

Change Lease Duration 30 Days, 8 Hours, 9 Minutes, 10 Seconds

Set-DhcpServerv4Scope -ComputerName $DHCPServer -ScopeID $Scope.ScopeId -LeaseDuration "30.08:09:10";