forked from okieselbach/Intune
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UploadBitLockerKeyProtectorType.ps1
45 lines (38 loc) · 1.52 KB
/
UploadBitLockerKeyProtectorType.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<#
.SYNOPSIS
Reads the BitLocker Key Protector Type for the OS drive und uploads to Azure table storage.
.DESCRIPTION
The script reads the BitLocker Key Protector Type for the OS Drive and uploads to Azure table storage.
The script is provided "AS IS" with no warranties.
.AUTHOR
Oliver Kieselbach (oliverkieselbach.com)
.EXAMPLE
UploadBitLockerKeyProtectorType.ps1
#>
$storageAccount = "" # fill here!!!
$sasToken = "" # fill here!!!
function Upload-BitLockerInfo($TableName, $PartitionKey, $RowKey, $entity) {
$version = "2017-04-17"
$resource = "$tableName(PartitionKey='$PartitionKey',RowKey='$Rowkey')$sasToken"
$table_url = "https://$storageAccount.table.core.windows.net/$resource"
$GMTTime = (Get-Date).ToUniversalTime().toString('R')
$headers = @{
'x-ms-date' = $GMTTime
"x-ms-version" = $version
Accept = "application/json;odata=fullmetadata"
}
$body = $entity | ConvertTo-Json
Invoke-RestMethod -Method PUT -Uri $table_url -Headers $headers -Body $body -ContentType application/json
}
$KeyProtectorType = ""
$(Get-BitLockerVolume $env:SystemDrive).KeyProtector | ForEach-Object {
if ($_.KeyProtectorType.ToString().ToLower().Contains("tpm")) {
$KeyProtectorType = $_.KeyProtectorType.ToString()
}
}
$body = @{
RowKey = $env:SystemDrive
PartitionKey = $env:COMPUTERNAME
KeyProtectorType = $KeyProtectorType
}
Upload-BitLockerInfo -TableName "BitLocker" -RowKey $body.RowKey -PartitionKey $body.PartitionKey -entity $body