Copying the ACL
1 |
Get-Acl sourceFile | Set-Acl targetFile |
Copy files with the ACL
1 |
robocopy source target /e /z /sec |
Add Permission on File
1 2 3 4 5 6 7 8 9 10 11 12 13 |
Function addFilePermission ($FileName, [string]$ACLUserName, [string]$Permission, [string]$Allow_Deny){ if ((Test-Path $FileName) -eq $True) { $file = Get-ChildItem $FileName $acl = $file.GetAccessControl() $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule ("$ACLUserName","$Permission","$Allow_Deny") $acl.AddAccessRule($accessrule) $file.SetAccessControl($acl) } else { Write-Host "The system cannot find the file specified." } } addFilePermission "fileName.txt" "olie" "FullControl" "Allow" |
fsutil behavior query disabledeletenotify
DisableDeleteNotify = 0
If Windows returned 0, TRIM is enabled.
Script prompt for password and automatically mount encrypted file into free drive letter volume. By default truecrypt.exe is stored in %FlashDiskDrive%:\truecrypt\truecrypt.exe and encrypted file is on root.
echo off
set TrueCryptPath=\truecrypt\truecrypt.exe
set TrueCryptFile=\vault01.tc
for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
cd %%a: 1>> nul 2>&1
if errorlevel 1 (
set FreeDrive=%%a:
)
)
Set Dir=%cd:~0%
Set Drive=%Dir:~0,2%
%Drive%%TrueCryptPath% /q /a /l%FreeDrive% /v %Drive%%TrueCryptFile%