function Invoke-IFileOperation {
    <#
    .SYNOPSIS
        Bootstrap function to expose an IFileOperation COM interface to powershell (script-scope).
    
    .DESCRIPTION
        Author: Ruben Boonen (@FuzzySec)
        License: BSD 3-Clause
        Required Dependencies: None
        Optional Dependencies: None
    
    .EXAMPLE
        C:\PS> Invoke-IFileOperation
        C:\PS> $IFileOperation.CopyItem("C:\Some\Dir\a.txt", "C:\Some\Other\Dir\", "b.txt")
        C:\PS> $IFileOperation.PerformOperations()
    #>
    
        # Compressed Dll which wraps the IFileOperation COM
        # Compression --> http://www.exploit-monday.com/2012/12/in-memory-dll-loading.html
        $EncodedCompressedFile = @'
        7Vt7fFx1lT/3kZnMJJk8GkoLAaZNS9PYhLzatFC0k8ykGTIvZiZ9YCXcmblJhk7mjvdO2oZSTBVRP4ACgqLAQl1YEFhhPwsfkccuAlbWFUHRBS0qiuKyvlBXF1Fkzzn3zp2ZJDzWP/y4n483ud/fOed3fud3fud3fr/7yE34nCtAAgAZz9dfB7gPzGMbvPUxj6fnlPs9cI/riVX3CaEnViWns4a3oGtTujLjTSv5vFb0plSvPpv3ZvNefzThndEyandDg3uNZSMWAAgJErT8/Ns7S3afh9XeOqEHAH/B    Ycry    EQQvnucx28S0aPoNUC7hJlNOhwTbPkiq9Fsu7YKPNrQbBdPutdLSg6zH4kch1H0bMbEP9K+2gq1FfrSC7y6qB4pYFrutcfWU/a4wcV63buhpsHxDH3mgfdV62/C3W1dzWtr0lSeGbG1apDe00M1YxCxHuUkNyDgxz3cACG9rkIuPV8WOZgC3dBkaOLGrTseiYLSg5AJTpC1DWmtFKFUeR5WidGg5lp0niwe5/JxZcpMNJ1UwHccjdap4IQn     +dBxJOleLrR01mCidp4pSa4eDKIBlPRLstXwyXcIucA5l8SKcbrljBUqKTqw7NEbCg4ReWby4SVuHBsSDpLrheNGsMFltLdYcCiMlb1huVsjaSrTTcQKN6R3c8Yk9NeAHjl     +z2IGZ5pA6PIhumYs6s51DOxGbOBlrWjWcT8f3Wp0bHE4N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Cvp4rM9tix79sZ9dePdao6/vx5lGyGsn+LWNMoCjo88n4JpoP9nWSzzwmfx9OJ9MMWQPinv5BiV7ZgzlUF+hud0rx1NQC3qM2rZy1p+l7zN/5/838pxj2GthrJZjHmxam7eLN4DHO/qtgujvjDmm7mNDzUMHlsKrc9hJN6q3V/02GZ+819451    +6478dfw3H/wI=
'@
    
        # Decompress & load assembly
        $DeflatedStream = New-Object IO.Compression.DeflateStream([IO.MemoryStream][Convert]::FromBase64String($EncodedCompressedFile),[IO.Compression.CompressionMode]::Decompress)
        $UncompressedFileBytes = New-Object Byte[](14336)
        $DeflatedStream.Read($UncompressedFileBytes, 0, 14336) | Out-Null
        [Reflection.Assembly]::Load($UncompressedFileBytes) | Out-Null
    
        # PS C:\Users\b33f> $IFileOperation |Get-Member
        # 
        #    TypeName: FileOperation.FileOperation
        # 
        # Name              MemberType Definition
        # ----              ---------- ----------
        # CopyItem          Method     void CopyItem(string source, string destination, string newName)
        # DeleteItem        Method     void DeleteItem(string source)
        # Dispose           Method     void Dispose(), void IDisposable.Dispose()
        # Equals            Method     bool Equals(System.Object obj)
        # GetHashCode       Method     int GetHashCode()
        # GetType           Method     type GetType()
        # MoveItem          Method     void MoveItem(string source, string destination, string newName)
        # NewItem           Method     void NewItem(string folderName, string name, System.IO.FileAttributes attrs)
        # PerformOperations Method     void PerformOperations()
        # RenameItem        Method     void RenameItem(string source, string newName)
        # ToString          Method     string ToString()
    
        $script:IFileOperation = New-Object FileOperation.FileOperation
    }