$keyword = 'Off'
$vms = Get-VM | Where-Object { $_.Name -like "*$keyword*" }
if (-not $vms) {
Write-Host "找不到 VM 名稱包含 '$keyword' 的虛擬機。" -ForegroundColor Yellow
return
}
$vmResults = @()
$grandTotalBytes = 0
foreach ($vm in $vms) {
$hdds = Get-VMHardDiskDrive -VMName $vm.Name -ErrorAction SilentlyContinue
if (-not $hdds) {
$vmResults += [pscustomobject]@{
VMName = $vm.Name
VhdCount = 0
TotalSizeGB = 0.0
Detail = "<無掛載虛擬硬碟>"
}
continue
}
無掛載虛擬硬碟>
Dino9021
技術記事與生活
2026-03-06
Get VM's Virtual Hard Disk Size with Keyword
2026-03-05
在 Windows 下讓 del 有個 alias name: rm
在 Windows 下讓 del 指令有個 alias name: rm
方法:
- 建立 C:\Windows\System32\rm.cmd
- 內容:
@echo off
del %*
2026-02-03
Open "Find Printers" by Hyperlink
Microsoft Edge
# AutoOpenFileTypes: qdsGPO: Computer Configuration → Administrative Templates → Microsoft Edge → List of file types that should be automatically opened on downloadNew-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Edge\AutoOpenFileTypes" -Force | Out-NullNew-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Edge\AutoOpenFileTypes" -Name "1" -Value "qds" -PropertyType String -Force | Out-Null# AutoOpenAllowedForURLs: 只允許 intranet.contoso.comGPO: Computer Configuration → Administrative Templates → Microsoft Edge → URLs where AutoOpenFileTypes can applyNew-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Edge\AutoOpenAllowedForURLs" -Force | Out-NullNew-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Edge\AutoOpenAllowedForURLs" -Name "1" -Value "intranet.contoso.com" -PropertyType String -Force | Out-Null
Google Chrome
2026-01-21
Make a Windows 11 Local Account Passwordless
Change this from 2 to 0
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\PasswordLess\Device]
"DevicePasswordLessBuildVersion"=dword:00000000
Create a .reg file with the following:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\PasswordLess\Device]
"DevicePasswordLessBuildVersion"=dword:00000000
Next:
Command: netplwiz
➨ Check: Users must enter a user name and password to use this computer
2026-01-08
Deploy Java Deployment Rule Set (Eneterprise White List)
所以需要設定企業白名單,而白名單需要進行數位簽章,所以還要有憑證架構
jdk1.8.0_202 Download
https://master.dl.sourceforge.net/project/msi-installers/msi-archive-files/Java/v8u31/jre-8u31-windows-i586.exe
先產生 ruleset.xml
<?xml version="1.0" encoding="UTF-8"?><ruleset version="1.0+"><rule><id location="https://plmap.contoso.com.tw/"/><action permission="run"/></rule><rule><id location="https://plmifs.contoso.com.tw:8080/"/><action permission="run"/></rule><rule><id/><action permission="default"/></rule></ruleset>
2025-12-31
Elevate privileges using PowerShell
2025-12-12
Configure IIS SMTP Service to receive mail over TLS and forward to a non-TLS SMTP service on one Windows Server
Scenario
- An older custom SMTP service only accepts unencrypted SMTP connections and does not support TLS.
- A solution is required to receive emails over TLS using IIS SMTP Service and relay them to the custom SMTP service without encryption.
- The goal must be achieved on a single virtual machine.
Environment Setup
Install two network interfaces on a single Windows Server with the following IP addresses:
- Network Interface 1:
10.11.11.11(physical NIC) - Network Interface 2:
10.22.22.22(Description: Microsoft KM-TEST Loopback Adapter)
2025-12-05
批次建立 win-acme 用 DNS Record 取得憑證的任務
批次建立 win-acme 用 DNS Record 取得憑證的任務
$RecordNames = @();
$RecordNames += "www";
$Domain = "contoso.com";
foreach ($RecordName in $RecordNames) {
$FQDN = ($RecordName + '.' + $Domain);
write-host ('Request Certificate for ' + $FQDN);
在 Azure DNS Zone 用 DNS Record 來驗證 Let's Encrypt 的 PowerShell Script
前情提要: 在 Microsoft DNS Server 上用 DNS Record 來驗證 Let's Encrypt 的 PowerShell Script
AzureDNSZoneVerification.ps1
2025-11-26
PowerShell 更新 IIS Site Bind SSL Cert
$PublishedURL = "www.contoso.com"
$IISSiteName = "www.contoso.com"
$PFXPath = "C:\Cert\Cert\"
$Password = "password"
$PFXFullPath = "$PFXPath$PublishedURL.pfx"
$pfx = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$pfx.Import($PFXFullPath, $Password, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::EphemeralKeySet)
Import-Module IISAdministration