2021-02-22

取得 PowerShell 執行 .ps1 的自身路徑與 pid

$MyInvocation.MyCommand (PowerShell 系統保留變數)

($MyInvocation.MyCommand).Path

$pid (PowerShell 系統保留變數)

寫入一個與 .ps1 主檔名相同、副檔名為 pid、內容為 pid 的檔案

2021-02-09

處理 Windows 10 / 2019 預設視窗邊界很難分辨的問題

不知道別人的情況如何
但我根本分辨不出來上層這個視窗的邊界在哪裡
所以無法辨別滑鼠游標要在哪裡按才能拖曳視窗

問題是,修改視窗標題、邊框顏色等功能又要先啟動作業系統後才能修改
微軟這真是莫名其妙、喪心病狂的設定...
只好出動註冊機碼來處理這件事

2021-02-03

Create Azure Site to Site VPN with PowerShell

Import-Module -Name Az

# Create a VNet with a Site-to-Site VPN connection using PowerShell
# https://docs.microsoft.com/en-us/azure/vpn-gateway/vpn-gateway-create-site-to-site-rm-powershell

$RegionLocation = 'Japan East';
$ResourceGroupName = 'Infra_Network';
$vNetName = 'Corp-vNet';

$VirtualNetworkGatewayPublicIPName = 'Azure_VPN_IP';
$VirtualNetworkGatewayName = 'Azure_VPN_Gateway';
$LocalNetworkGatewayName = 'Local_VPN_Gateway';
$AzureVPNConnectionName = 'Azure_VPN_Connection';
$VPNSharedKey = (("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".tochararray() | sort {Get-Random})[0..32] -join '');

$GatewaySku = 'Basic';
$LocalNetworkIPAddress = '168.95.1.1';
$LocalNetworkAddressSpace = @('10.255.0.0/16');

$LocalRRAS_VPNName = 'AzureVPN';
$LocalDNSServer_Object = New-Object -Type PSObject -Property @{"DnsServers" = @("10.10.10.11")};