2026-03-06

Get VM's Virtual Hard Disk Size with Keyword

$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
   }

2026-03-05

在 Windows 下讓 del 有個 alias name: rm

在 Windows 下讓 del 指令有個 alias name: rm

方法:

  • 建立 C:\Windows\System32\rm.cmd
  • 內容:
    @echo off
    del %*
結果: c:\> rm a.txt
等於: c:\> del a.txt

2026-02-03

Open "Find Printers" by Hyperlink



Microsoft Edge

# AutoOpenFileTypes: qds
GPO: Computer Configuration → Administrative Templates → Microsoft Edge → List of file types that should be automatically opened on download
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Edge\AutoOpenFileTypes" -Force | Out-Null
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Edge\AutoOpenFileTypes" -Name "1" -Value "qds" -PropertyType String -Force | Out-Null

# AutoOpenAllowedForURLs: 只允許 intranet.contoso.com
GPO: Computer Configuration → Administrative Templates → Microsoft Edge → URLs where AutoOpenFileTypes can apply
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Edge\AutoOpenAllowedForURLs" -Force | Out-Null
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Edge\AutoOpenAllowedForURLs" -Name "1" -Value "intranet.contoso.com" -PropertyType String -Force | Out-Null
          Verify: edge://policy


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)

由於 PLM 版本太舊,其中的 Java 程式憑證過期,使用者使用時會彈出警告視窗
所以需要設定企業白名單,而白名單需要進行數位簽章,所以還要有憑證架構

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>