HP EliteBook 745 Sure Recover User Guide - Page 13

encoding = New-Object System.Text.UTF8Encoding $False

Page 13 highlights

$header = "mft_version=1, image_version=$imageVersion" Out-File -Encoding UTF8 -FilePath $mftFilename -InputObject $header $swmFiles = Get-ChildItem "." -Filter "*.swm" $ToNatural = { [regex]::Replace($_, '\d args[0].Value.PadLeft(50) }) } $pathToManifest = (Resolve-Path ".").Path $total = $swmFiles.count $current = 1 $swmFiles | Sort-Object $ToNatural | ForEach-Object { Write-Progress -Activity "Generating manifest" ` -Status "$current of $total ($_)" ` -PercentComplete ($current / $total * 100) $hashObject = Get-FileHash -Algorithm SHA256 -Path $_.FullName $fileHash = $hashObject.Hash.ToLower() $filePath = $hashObject.Path.Replace($pathToManifest fileSize = (Get-Item $_.FullName).length $manifestContent = "$fileHash $filePath $fileSize" Out-File -Encoding utf8 -FilePath $mftFilename -InputObject $manifestContent -Append $current = $current + 1 } NOTE: Manifests for HP Sure Recover cannot include a BOM, so the following commands rewrite the file as UTF8 without BOM. $content = Get-Content $mftFilename $encoding = New-Object System.Text.UTF8Encoding $False Creating a manifest 7

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

$header = "mft_version=1, image_version=$imageVersion"
Out-File -Encoding UTF8 -FilePath $mftFilename -InputObject $header
$swmFiles = Get-ChildItem "." -Filter "*.swm"
$ToNatural = { [regex]::Replace($_, '\d*\
....
$',
{ $args[0].Value.PadLeft(50) }) }
$pathToManifest = (Resolve-Path ".").Path
$total = $swmFiles.count
$current = 1
$swmFiles | Sort-Object $ToNatural | ForEach-Object {
Write-Progress
-Activity "Generating manifest" `
-Status "$current of $total ($_)" `
-PercentComplete ($current / $total * 100)
$hashObject = Get-FileHash -Algorithm SHA256 -Path $_.FullName
$fileHash = $hashObject.Hash.ToLower()
$filePath = $hashObject.Path.Replace($pathToManifest + '\', '')
$fileSize = (Get-Item $_.FullName).length
$manifestContent = "$fileHash $filePath $fileSize"
Out-File -Encoding utf8 -FilePath $mftFilename -InputObject
$manifestContent -Append
$current = $current + 1
}
NOTE:
Manifests for HP Sure Recover cannot include a BOM, so the following commands rewrite the
file
as UTF8 without BOM.
$content = Get-Content $mftFilename
$encoding = New-Object System.Text.UTF8Encoding $False
Creating a manifest
7