$ErrorActionPreference = "Stop"
$dir = "$env:PUBLIC\Documents\EFS_LR5"
$encrypted = Join-Path $dir "Folder_EFS"
$plain = Join-Path $dir "Folder_Plain"
# Create two folders
New-Item -ItemType Directory -Force -Path $encrypted, $plain | Out-Null
# Create file BEFORE encryption
"File created before EFS encryption" |
Set-Content "$encrypted\before.txt"
Write-Host "`n=== ENCRYPT FOLDER ===" -ForegroundColor Cyan
# Encrypt folder and existing files
cipher /e "/s:$encrypted"
# Create file AFTER encryption
"File created after EFS encryption" |
Set-Content "$encrypted\after.txt"
# Create another file and move it into encrypted folder
"File moved from unencrypted folder" |
Set-Content "$plain\imported.txt"
Move-Item "$plain\imported.txt" "$encrypted\imported.txt" -Force
Write-Host "`n=== ENCRYPTION STATUS ===" -ForegroundColor Green
cipher "$encrypted"
Write-Host "`n=== FILE CONTENTS ==="
Get-ChildItem $encrypted | Select-Object Name, Length
explorer.exe $encrypted
$dir = "$env:PUBLIC\Documents\EFS_LR5"
Move-Item "$dir\Folder_EFS\after.txt" `
"$dir\Folder_Plain\after_moved.txt"
cipher "$dir\Folder_Plain"