Windows 11 移除預先佈建的應用程式 (Provisioned Package)

Provisioned Package (預先佈建的應用程式)

PowerShell
    
# 列出目前的 Provisioned Package:
Get-AppxProvisionedPackage -Online | Format-Table DisplayName, PackageFullName
    
  
PowerShell
    
# 除特定的 Provisioned App:
Remove-AppxProvisionedPackage -Online -PackageName <packagefullname>
Get-AppxProvisionedPackage -Online | Where-Object {$_.DisplayName -like "*Xbox*"} | Remove-AppxProvisionedPackage -Online
    <packagefullname>
    	
	
PowerShell
    
# 移除所有使用者已安裝和預先布建的 AppxPackage:
$packagefullname = (Get-AppxProvisionedPackage -online | Where-Object {$_.DisplayName -like "*應用程式名稱*"}).PackageFullName
if ($packagefullname) {
    Get-AppxPackage -AllUsers | Where-Object {$_.PackageFullName -like $packagefullname} | Remove-AppxPackage
    Remove-AppxProvisionedPackage -online -PackageName $packagefullname
}	
    
  

客製 Windows 11 安裝光碟

假設 
install.wim 所在目錄為:D:\CustomWin11 
wim 掛載目錄:D:\CustomWin11\WIM
將索引3 中指定的 AppXProvisioned Package 移除
 
PowerShell
    
# 列出 install.wim 的索引資訊:
dism /get-wiminfo /wimfile:D:\CustomWin11\install.wim
    
  

上圖可知,此映像有五個索引,所以要針對每一個索引做處理
PowerShell
    
# 掛載每個索引 範例
dism /mount-wim /wimfile:D:\CustomWin11\install.wim /index:3 /mountdir:D:\CustomWin11\WIM
    
  
PowerShell
    
# 列出預配置的應用
dism /image:D:\CustomWin11\WIM /get-provisionedappxpackages
    
  
PowerShell
    
# 移除不需要的應用
dism /image:D:\CustomWin11\WIM /remove-provisionedappxpackage /packagename:Microsoft.YourAppName_*
    
  
PowerShell
    
$apps=@( 	
	#"Microsoft 新聞、搜尋、天氣"
	"*Bing*"
	#"Xbox"
	"*xbox*"
	"*Gaming*"
	#"Office 365"
	"*MicrosoftOfficeHub*"
	#"Solitaire & Casual Games"
	"*SolitaireCollection*"
	#"Outlook for Windows"
	"*OutlookForWindows*"
	#"Goove Music"
	"*ZuneMusic*"
	#"Microsoft To Do"
	"*Microsoft.Todos*"
	#"Microsoft.Windows.DevHome"
	"*Windows.DevHome*"
	#"Microsoft.WindowsFeedbackHub"
	"*Microsoft.WindowsFeedbackHub*"
	#"Microsoft.Xbox"
	"*Microsoft.Xbox*"
)
#========== Remove selected AppXProvisioned Package ==========
foreach ($app in $apps) {	
	Get-AppXProvisionedPackage -path .\WIM | where DisplayName -like ("*" + $app + "*") | Remove-AppxProvisionedPackage
    }
    
  
PowerShell
    
# 保存並卸載映像
dism /unmount-wim /mountdir:D:\CustomWin11\WIM /commit
    
  
完成後,將修改過的 install.wim 放至欲建立的 ISO 目錄中,然後製作成 ISO 檔:
    
# 製作成 ISO 檔
.\oscdimg -pEF -u1 -udfver102 -bd:\CustomWin11\Win11ISO\efi\microsoft\boot\efisys.bin d:\CustomWin11\Win11ISO\ d:\CustomWin11\Win11.iso -lWin11_24H2_tw_202412_-AppXProvisioned
    
  

Block ICMP timestamp on FortiGate interface (CVE-1999-0524)

 今年的弱掃,被掃出一個 low 等級弱點:『ICMP Timestamp Request Remote Date Disclosure』:

"The remote host answers to an ICMP timestamp request.  This allows an attacker to know the date that is set on the targeted machine, which may assist an unauthenticated, remote attacker in defeating time-based authentication protocols." (遠端主機會回應 ICMP 時間戳請求。這使得攻擊者能夠知道目標機器上設置的日期,這可能會幫助未經身份驗證的遠程攻擊者破解基於時間的身份驗證協議。)

如果是無對外的服務,基本上可以略過。

基於方便除錯,Firewall Wan Port 上有開啟 Ping 服務,所以要排除這個弱點,就要在 Firewall 做設定。
這個弱點是利用 ICMP Type13 功能,所以要在 Firewall 上禁用,Fortigate 的設定如下:

Ref: Block ICMP timestamp on FortiGate interface while keeping ping enabled

  1. Create a firewall service for ICMP type 13 (timestamp request):(7.2.x已內建)

     config firewall service custom

    edit "TIMESTAMP"

        set protocol ICMP

        set icmptype 13

    next

end

 

  1. Create address entry for wan1 interface IP: 

config firewall address

    edit "wan1-IP"

        set subnet 1.1.1.1 255.255.255.255 (該 Wan 埠 IP)

    next

end

 

  1. Create local-in-policy to block timestamp requests on wan1 interface IP: 

config firewall local-in-policy

    edit 1

        set intf "wan1"

        set srcaddr "all"

        set dstaddr "wan1-IP"

        set service "TIMESTAMP"

        set schedule "always"

        set action deny

    next

end

RECOVERING DELETED PARTITION USING TESTDISK

 做了蠢事,誤刪非目標的 RAID 配置。

記錄一下救回的過程,順便介紹好用的免費工具 TestDisk 

介紹一下犯錯的環境:

  • HPE DL380G9 w/ Smary Array P440ar
    • RAID 6 w/ 480G*12
  • Windows 2019 STD
    • GPT Partation

通常 RAID 設定被刪除,原廠的文就應該都是請你從備份資料還原。

但多數的 RAID 配置刪除,是不會刪除實際資料,如果你還記得該 RAID 的配置參數,理論上是有機會可以救回來的。以下參數必須一樣:

  • RAID 等級,如 RAID1RAID6,以及成員磁碟 (在多磁碟的環境)
  • Logical Drive Strip Size / Full Strip Size
    (
    如果 Array 分成多個 Logical Drive,那必須依原始配置的大小和順序)
  • 分割區的類型,如 MBRGPT….
  • 我的經驗 HPEIntelLSI RAID Card 都可以 (好像常犯錯 Orz)

Tips:由於掃描磁碟會花很久的時候。磁碟容量越大,時間需要越久。這時候要抉擇救援還是從備份還原或兩案並進,因為救援有可能失敗,超出RTORecovery Time Objective)目標。

還原過程:

1.        執行 Testdisk,選擇是否要輸出Log記錄(如果使用 LiveCD 類,當然無法輸出)


2.        選擇要救援的磁碟


3.        選擇當初的磁碟分割表類型



4.        選擇『Analyse』來找出被刪除的分割區



5.        會先顯示目前存在的分割區,選擇[Quick Search]來搜尋刪除的分割區



6.        搜尋完畢後,會列出找到的分割區,利用上下鍵選取欲還原的分割區,並另用左右鍵設定其分割區屬性



7.        確認無誤後,選擇 [Write] 將欲還原的分割區寫入磁碟
!!
如果[Quick Search]沒找到你要的分割區,還可以選擇[Deeper Search]試試看 !!



8.        系統會提醒重開機,以生效設定值。



9.        大功告成。希望大家都不會用到這個資訊,也祈禱用到時都能救回來。

 

HP Smart array CLI commands

 

HP Smart array CLI commands

Show configuration

/opt/hp/hpssacli/bin/hpssacli ctrl all show config

Controller status

/opt/hp/hpssacli/bin/hpssacli ctrl all show status

Show detailed controller information for all controllers

/opt/hp/hpssacli/bin/hpssacli ctrl all show detail

Show detailed controller information for controller in slot 0

/opt/hp/hpssacli/bin/hpssacli ctrl slot=0 show detail

Rescan for New Devices

/opt/hp/hpssacli/bin/hpssacli rescan

Physical disk status

/opt/hp/hpssacli/bin/hpssacli ctrl slot=0 pd all show status

Show detailed physical disk information

/opt/hp/hpssacli/bin/hpssacli ctrl slot=0 pd all show detail

Logical disk status

/opt/hp/hpssacli/bin/hpssacli ctrl slot=0 ld all show status

View Detailed Logical Drive Status

/opt/hp/hpssacli/bin/hpssacli ctrl slot=0 ld 2 show

Create New RAID 0 Logical Drive

/opt/hp/hpssacli/bin/hpssacli ctrl slot=0 create type=ld drives=1I:1:2 raid=0

Create New RAID 1 Logical Drive

/opt/hp/hpssacli/bin/hpssacli ctrl slot=0 create type=ld drives=1I:1:1,1I:1:2 raid=1

Create New RAID 5 Logical Drive

/opt/hp/hpssacli/bin/hpssacli ctrl slot=0 create type=ld drives=1I:1:1,1I:1:2,2I:1:6,2I:1:7,2I:1:8 raid=5

Delete Logical Drive

/opt/hp/hpssacli/bin/hpssacli ctrl slot=0 ld 2 delete

Add New Physical Drive to Logical Volume

/opt/hp/hpssacli/bin/hpssacli ctrl slot=0 ld 2 add drives=2I:1:6,2I:1:7

Add Spare Disks

/opt/hp/hpssacli/bin/hpssacli ctrl slot=0 array all add spares=2I:1:6,2I:1:7

Enable Drive Write Cache

/opt/hp/hpssacli/bin/hpssacli ctrl slot=0 modify dwc=enable

Disable Drive Write Cache

/opt/hp/hpssacli/bin/hpssacli ctrl slot=0 modify dwc=disable

Erase Physical Drive

/opt/hp/hpssacli/bin/hpssacli ctrl slot=0 pd 2I:1:6 modify erase

Turn on Blink Physical Disk LED

/opt/hp/hpssacli/bin/hpssacli ctrl slot=0 ld 2 modify led=on

Turn off Blink Physical Disk LED

/opt/hp/hpssacli/bin/hpssacli ctrl slot=0 ld 2 modify led=off

Modify smart array cache read and write ratio (cacheratio=readratio/writeratio)

/opt/hp/hpssacli/bin/hpssacli ctrl slot=0 modify cacheratio=100/0

Enable smart array write cache when no battery is present (No-Battery Write Cache option)

/opt/hp/hpssacli/bin/hpssacli ctrl slot=0 modify nbwc=enable

Disable smart array cache for certain Logical Volume

/opt/hp/hpssacli/bin/hpssacli ctrl slot=0 logicaldrive 1 modify arrayaccelerator=disable

Enable smart array cache for certain Logical Volume

/opt/hp/hpssacli/bin/hpssacli ctrl slot=0 logicaldrive 1 modify arrayaccelerator=enable

Enable SSD Smart Path

/opt/hp/hpssacli/bin/hpssacli ctrl slot=0 array a modify ssdsmartpath=enable

Disable SSD Smart Path

/opt/hp/hpssacli/bin/hpssacli ctrl slot=0 array a modify ssdsmartpath=disable

Domain User 無法使用 Windows Hello 等生物辨識登入

 Doamin User 預設無法使用 生物/指紋、Windows Hello...等辨識功能登入網域。

使用群組原則:
    【電腦設定】→【原則】→【系統管理範本】→【Windows 元件】→【生物辨識技術】→【】
    【Computer Configuration】→【Polices】→【Administrative Templates】→【Windows Components】→【Biometrics】


允許使用生物識別                                → 允許

允許使用者使用生物識別登入         →    允許(本機使用者)
(Allow users to log on using biometrics)
允許網域使用者使用生物識別登入    →    不允許
(Allow domain users to log on using biometrics)

Windows 新增電源模式

Ref: How to enable Ultimate Performance mode in Windows 10
Ref: 如何在Win10裡透過Powercfg命令列調整電源選項

 powercfg -duplicatescheme {GUID}

電源配置 GUID: 381b4222-f694-41f0-9685-ff5bb260df2e  (平衡)

電源配置 GUID: 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c  (高效能)

電源配置 GUID: a1841308-3541-4fab-bc81-f71556f20b4a  (省電)

電源配置 GUID: e9a42b02-d5df-448d-aa00-03f14749eb61  (終極效能)

Get AD account Password ExprityTime

Way1:

net user %username% /domain

Way2:(Powershell)

Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False} –Properties "Name", "msDS-UserPasswordExpiryTimeComputed" | Sort-Object -Property "msDS-UserPasswordExpiryTimeComputed" | Select -Property "Name",@{Name="ExpiryDate";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}}


!! 待加強
1. Filter by Day
2. Send-MailMessage -from "Helpdesk <helpdesk@noreply.com>" -to "$firstname $surname<$user.mail>" -subject "Password Expiration in $diff days" -smtp "smtpserver" -body $body

Domain Control Time sync on Hyper-V

基本上,現在低負載 SERVER,大都灌在 VM 上。而 Guest OS 預設會與 VM Host 做時間同步。
VM Host 如果有加入網域,就會跟 Logon DC 同步時間。

然而,一般的 DC / PDC 也都會灌在 VM 上,這樣時間同步就變成一個 Dead Loop。
為避免此情形,必須將 DC 與 VM 的時間同步關閉,並設定 DC 的 NTP Server。

以 Hyper-V 為例:

1. 關閉 Guset OS 與 Hyper-V  的時間同步

2. 將 DC / PDC 的 NTP 設為 time.windows.com
  • w32tm /config /manualpeerlist:time.windows.com /syncfromflags:manual /reliable:yes /update
  • Restart-Service w32time



Edgd / Chrome Windows 整合式驗證 (WIA)

Ref: Security Zones in Edge
Ref: 使用者登入 Microsoft Edge 的方式
Ref: Per-site configuration by policy
Ref: 如何透過群組原則(GPO)將內部網站加入 近端內部網路 清單

Windows 整合式驗證 (WIA)

Microsoft Edge 也支援在組織內部網路中針對使用瀏覽器進行其驗證的任何應用程式,進行驗證要求的 Windows 整合驗證。 所有版本的 Windows 10 和舊版 Windows 都支援這項功能。 根據預設,Microsoft Edge 會使用內部網路區域作為 WIA 的允許清單

透過群組原則(GPO),將 URL 加入 「區域清單」

內部網路區域(1) /  信任的網站區域(2) / 網際網路區域(3) / 受限制的網站區域(4)
Ref: Site to Zone Assignment List(指派網站到區域清單)

〔使用者設定〕→〔系統管理範本〕→〔Windows 元件〕→〔Internet Explorer〕→〔網際網路控制台〕→〔安全性畫面〕→〔指派網站到區域清單〕(Site to Zone Assignment List)

Windows 聲音輸出到多個裝置 (利用Virtual Audio Cable)

Windows 無法將聲音同時輸出到多個裝置,想要達到這個目錄,可以使用Virtual Audio Cable (VAC),請到 VAC 的官網去下載 https://vac.muzychenko.net/en/。

下載安裝後,會多了一個 『Line 1 (Virtual Audio Cable)』音訊裝置,並預設為預設撥放裝置,如下圖:。


再來開啟 『Audio Repeater』,Wave In 選擇 「Line 1」,Wave In 選擇你要輸出的裝置1。
之後要輸出的裝置,重複上個步驟(也就是想同時輸出幾個裝置,就開執行幾個『Audio Repeater』。


Fortigate IPS, DNS/WEB Filter, Domain & IP Reputation

 Fortigate 啟用 Fortigate IPS, DNS/WEB Filter, Domain & IP Reputation 相關功能

  • 在 Fortigate 要使用一些功能,必須先到[Feature Visibility] 中啟用該功能。

  • DNS Filter
  • Apply DNS category filtering, URL filtering to control user's access to web resources. Set up DNS Filter Profiles (Security Profiles > DNS Filter) and add them to Firewall Policies or add them to a DNS Server on a FortiGate interface. Some features require a subscription to FortiGuard Web Filtering.
  • Web Filter
  • Apply web category filtering, URL filtering, and content filtering to control user's access to web resources. Set up Web Filter Profiles (Security Profiles > Web Filter) and add them to Firewall Policies. Some features require a subscription to FortiGuard Web Filtering.
  • 前兩項,個人認為比較偏向 Client (Outgoing),避免去到惡意的網站或網址

  • Domain & IP Reputation
  • Enable the Reputation Lookup feature. This page allows querying of reputations for IPs or FQDNs as classified in FortiGuard databases. Databases require a valid FortiGuard subscription.
  • Intrusion Prevention
  • Detect and block network-based attacks. Set up IPS Sensors (under Security Profiles > Intrusion Prevention) and add them to Security Policies. Requires a subscription to FortiGuard IPS.
  •  在[Intrusion Prevention],可{Disable | Block | Monitor} [Botnet C&C]  
  • 後兩項,偏向 Server (Incoming),避免已知惡意來源的連線

  • Domain & IP Reputation
  • Enable the Reputation Lookup feature. This page allows querying of reputations for IPs or FQDNs as classified in FortiGuard databases. Databases require a valid FortiGuard subscription.
  • 此項目在自訂 Domain / IP List。用來定義黑名單。 
  • External Block List (Threat Feed)

    如何建立外部的 IP 封鎖清單

    # Explame Paltfrom: Fortigate 20xE / 6.2.11

    Ref:Fortigate Threat feeds(6.2.x)
    Ref:External Block List (Threat Feed) – Policy(6.2.0) 
    Ref:All Cybercrime IP Feeds by FireHOL

    • [Security Fabric] → [Fabric Connectors]  → [Create New] → [IP Address]
    • 以 [https://raw.githubusercontent.com/ktsaou/blocklist-ipsets/master/firehol_level1.netset] 為 List 來源
    • 在 Policy 引用 (記得 Block Deny Policy 要在前面)
    • 建議搭配 [Intrusion Prevention]及其Block [Botnet C&C]、DNS Filter、Web Filter