跳转到主要内容
BitLocker 金鑰、輪替本機管理員密碼、第三方 UID 等。 你可以透過指令稿寫入自訂資產欄位。這對於 BitLocker 金鑰、輪替本機管理員密碼與第三方 UID 等都很有用。
1

建立自訂資產欄位

  1. 前往 Settings > Assets > Custom Fields
  2. 新增自訂欄位,內容如下:
  • Name:BitLocker Recovery Key
  • Variable:bitlockerRecoveryKey
Image
2

建立指令稿

  1. 前往 Scripts
  2. 建立指令稿,內容如下:
  • Name:🗝️Store-BitlockerRecoveryKey
  • Content
$ErrorActionPreference = 'SilentlyContinue' 

# Get drives where BitLocker is "On" 
$BitlockerDrives = Get-BitLockerVolume | Where-Object ProtectionStatus -EQ "On" -ErrorAction SilentlyContinue

#Get FileSystem drives 
$Drives = Get-PSDrive -PSProvider FileSystem

#Create array of Drive Names with ":" added
$DrivesName = @()
$Drives |  foreach {$DrivesName += $_.name + ':' }

#If any Bitlockered drives exist
if($BitlockerDrives){

    #Foreach Drive
    Foreach ($DriveName in $DrivesName) {

        #Confirm is drive is bitlockered
        $BitlockerDrive = $BitlockerDrives | where { $DriveName -contains $_ }

        #If specific drive is bitlockered
        if ($BitlockerDrive){

            #Get RecoveryKey 
            $RecoveryKey = $BitlockerDrive.KeyProtector | Where-Object RecoveryPassword -NE "" | Select-Object -ExpandProperty RecoveryPassword -ErrorAction SilentlyContinue
      
            #Join if multiple with ; delimiter 
            $RecoveryKey = $RecoveryKey -join ";"

            #Add the drive letter to the output
            $RecoveryKey = "$($BitlockerDrive.mountpoint)$RecoveryKey"

            #Add to other drive keys (If exist)
            $RecoveryKeys += " $RecoveryKey "

        } else { $RecoveryKeys += $DriveName + "Not Enabled" }   
        
    }

    GoreloAction -SetCustomField -Name 'asset.bitlockerRecoveryKey' -Value $RecoveryKeys

#If no bitlockered drives found
}else { 
    
    Foreach ($DriveName in $DrivesName) { 
        
        $RecoveryKeys += $DriveName + "Not Enabled " 
        
    } 
    
    GoreloAction -SetCustomField -Name 'asset.bitlockerRecoveryKey' -Value $RecoveryKeys 
    
}
3

透過政策部署指令稿。

  1. 前往 Policies
  2. 編輯涵蓋你想儲存金鑰或位址之資產的現有政策。
  3. 新增該指令稿並設定每天於你偏好的時間重複執行。
  4. Save 並分發政策。