Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$FAD,$kernel32 = Add-Type @'
using System;
using System.IO;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential)]
public struct WIN32_FILE_ATTRIBUTE_DATA
{
public FileAttributes dwFileAttributes;
public System.Runtime.InteropServices.ComTypes.FILETIME ftCreationTime;
public System.Runtime.InteropServices.ComTypes.FILETIME ftLastAccessTime;
public System.Runtime.InteropServices.ComTypes.FILETIME ftLastWriteTime;
public uint nFileSizeHigh;
public uint nFileSizeLow;
}
public class Kernel32
{
[DllImport("kernel32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetFileAttributesEx(string lpFileName, int fInfoLevelId, out WIN32_FILE_ATTRIBUTE_DATA lpFileInformation);
}
'@ -PassThru
$EncryptedFiles = [System.IO.Directory]::EnumerateFiles($PWD, '*', [System.IO.SearchOption]::AllDirectories).ForEach({
$attrData = [System.Activator]::CreateInstance($FAD)
if([Kernel32]::GetFileAttributesEx("$_", 0, [ref]$attrData) -and $attrData.dwFileAttributes.HasFlag([System.IO.FileAttributes]::Encrypted)){
[System.IO.FileInfo]$_
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.