Загрузка данных



$ErrorActionPreference = "Stop"

$name = "EFS_Lab2"
$dir = "$env:PUBLIC\Documents\EFS_LR5"

# Create local user
if (-not (Get-LocalUser -Name $name -ErrorAction SilentlyContinue)) {
    $password = Read-Host "Set password for EFS_Lab2" -AsSecureString

    New-LocalUser -Name $name `
        -Password $password `
        -Description "EFS laboratory user 2"
}

# Grant NTFS permissions to test files
$account = "$env:COMPUTERNAME\$name"

icacls "$dir\File_1.txt" /grant "${account}:(R)"
icacls "$dir\File_2.txt" /grant "${account}:(M)"

Write-Host "`nUSER CREATED:" -ForegroundColor Green

Get-LocalUser -Name $name |
    Select-Object Name, Enabled, Description