2024-01-30

Windows Firewall Block Public InBound 80 Port

Windows Firewall Block Public InBound 80 Port

$FWGroupName = "BlockPublicInBound80Port";

# Remove Rule
$Remove = New-NetFirewallRule -DisplayName "RemovePrepare" -Group $FWGroupName -Direction inbound -Program "C:\windows\system32\calc.exe" -Action Block -RemoteAddress $BlockIPs
Remove-NetFirewallRule -Group $FWGroupName -Confirm:$False

# Add Rule
$BlockIPs = @("0.0.0.1-9.255.255.255", "11.0.0.0-172.15.255.255", "172.32.0.0-192.167.255.255", "192.169.0.0-255.255.255.255")
New-NetFirewallRule -DisplayName "Block 80 Port inBound" -Group $FWGroupName -Direction "inBound" -Protocol "TCP" -LocalPort 80 -Action Block -RemoteAddress $BlockIPs

2023-12-12

40號桌。

40號桌。

在等待慣性遲到的她抵達之前,先見到的竟是我相依為命的母親。母親在那套著縫縫補補椅套的桌前坐了下來,我問:「待會兒她來了,妳是要去樓上吃飯還是先回家?」母親眼睛咕溜溜地轉了一下,停了半晌:「我先回去好了。」登時心中五味雜陳:『我沒有趕妳回去的意思呀。』

就在母親起身時,貌似老年癡呆的感覺襲上心頭,而遠處見到她正向這裡走來。於是夢醒了,沒有見著她長得什麼模樣,臉是一團模糊的馬賽克。

『嘛,還好只是個夢』

2023-08-30

PowerShell Script to Change Public IP Address of VM on Azure

需搭配 Connect-AzAccount with Saved Encryped Credential in Powershell 實現自動化


Param (
    [String]$VMName = ''
);

if ($VMName -eq '') {
    exit;
};

Set-Location -Path ('C:\ChangeVMPublicIP');

if (Test-Path -Path (($VMName) + '.Lock')) {
    if ((Get-Date) -lt (Get-Item -Path (($VMName) + '.Lock')).LastWriteTime.AddMinutes(5)) {
        write-Host 'VM Locked';
        exit;
    };
};
$VMName | Out-File (($VMName) + '.Lock');

$CredentailFileName = 'AzCredential.txt';
$AzSubscriptionID = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';

2023-08-28

PowerShell 取得 UTF-8 中英文夾雜之字串長度

  $StringLength = 0;
foreach ($Word in ($String -Split '')) {
if ([System.Text.Encoding]::UTF8.GetByteCount($Word) -gt 1) {
$StringLength += 2;
} else {
$StringLength += [System.Text.Encoding]::UTF8.GetByteCount($Word);
};
};

2022-10-06

Enable support for TLS 1.2 for Microsoft Cloud Service (Exchange、AVD、Teams....etc.)

近幾個月微軟更新雲端服務,幾乎各種連線都開始只支援 TLS 1.2
如果還沒更新或開啟的話就會出現各種連不上、帳號驗證失敗等等問題
參考微軟說明開啟即可

Update to enable TLS 1.1 and TLS 1.2 as default secure protocols in WinHTTP in Windows

上述網頁中的 EasyFix 直連按這裡

或是跑 PowerShell

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force

If (-Not (Test-Path 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\.NETFramework\v4.0.30319')) {
    New-Item 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\.NETFramework\v4.0.30319' -Force | Out-Null;
};

2022-10-04

Store Birlocker Recovery Password To AD via GPO and Powershell

Computer Configuration (Enabled)
=> Policies
=> => Windows Settings
=> => => Scripts
=> => => => Startup
=> => => => => StoreBitlockerRecoveryRasswordToAD.ps1  

=======================================================
ACL Add Allow Domain Computers to Read and Execute
=======================================================
$keyID = Get-BitLockerVolume -MountPoint c: | select -ExpandProperty keyprotector |  where {$_.KeyProtectorType -eq 'RecoveryPassword'};

if ($keyID.KeyProtectorId -ne $Null) {
Backup-BitLockerKeyProtector -MountPoint c: -KeyProtectorId $keyID.KeyProtectorId;
};

=======================================================

2022-10-03

Deal with Azure Virtual Desktop FSLogix failed to attach user profile disk (Open File)

User 在登入 Azure Virtual Desktop 的時候出現無法掛載 User Profile Disk 的問題
經過檢查該 User 沒有任何殘留的 Session 在同一個 Host Pool 的任何一台 Session Host 上
思考方向是 User Profile Disk 在某個 Sign-out event 沒有被正常 Detached 導致 Open File 的問題


處理方式:

以 PoweShell 先登入 Azure Account

    Connect-AzAccount

選取可管理該 User Profile Disk 所存放 Storage Account 的 Subscription

    Select-AzSubscriptionSelect -subscriptionid 'oooooo-xxxxx-oooo-oooo-xxxxxxx'

2022-09-29

Password Recover for Remote Desktop Connection Manager (RDCM 密碼找回)

  1. 把 RDCMan.exe Copy 並變更副檔名為 dll => RDCMan.dll
  2. PowerShell 指令: Import-module [Path]\RDCMan.dll
  3. 用純文字編輯軟體 (ex: Notepad、Notepad++) 開啟儲存的 RDCM.rdg 檔案
  4. 找到需要的連線目標項目裡面的 <password> 段並複製該段內容
  5. 揮揮魔法棒實現還原魔法