Skip to content

Commit

Permalink
Merge pull request #132 from ThePoShWolf/master and !Deploy
Browse files Browse the repository at this point in the history
Fix for #131, supports PS Core
  • Loading branch information
RamblingCookieMonster authored Jun 28, 2020
2 parents cc45550 + c107e70 commit e7cd226
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions PSDeploy/Private/Invoke-Robocopy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
.Parameter PassThru
Switch. Returns an object with the following properties:
StdOut - array of strings captured from StandardOutput
StdErr - array of strings captured from StandardError
StdOut - array of strings captured from StandardOutput
StdErr - array of strings captured from StandardError
ExitCode - Enum with Robocopy exit code in human-readable format
By default, this function doesn't generate any output.
Expand Down Expand Up @@ -76,26 +76,26 @@ function Invoke-Robocopy
if (! ([System.Management.Automation.PSTypeName]$TypeName).Type) {
try {
#region Module Builder
$Domain = [System.AppDomain]::CurrentDomain
$DynAssembly = New-Object -TypeName System.Reflection.AssemblyName($TypeName)
$AssemblyBuilder = $Domain.DefineDynamicAssembly($DynAssembly, [System.Reflection.Emit.AssemblyBuilderAccess]::Run) # Only run in memory
$Domain = [System.AppDomain]::CurrentDomain
$DynAssembly = New-Object -TypeName System.Reflection.AssemblyName($TypeName)
$AssemblyBuilder = [System.Reflection.Emit.AssemblyBuilder]::DefineDynamicAssembly($DynAssembly, [System.Reflection.Emit.AssemblyBuilderAccess]::Run) # Only run in memory
$ModuleBuilder = $AssemblyBuilder.DefineDynamicModule($TypeName, $false)
#endregion Module Builder

# https://pshirwin.wordpress.com/2016/03/18/robocopy-exitcodes-the-powershell-way/
#region Enum
$EnumBuilder = $ModuleBuilder.DefineEnum($TypeName, 'Public', [int32])
[void]$EnumBuilder.DefineLiteral('NoChange', [int32]0x00000000)
[void]$EnumBuilder.DefineLiteral('OKCopy', [int32]0x00000001)
[void]$EnumBuilder.DefineLiteral('ExtraFiles', [int32]0x00000002)
[void]$EnumBuilder.DefineLiteral('MismatchedFilesFolders', [int32]0x00000004)
[void]$EnumBuilder.DefineLiteral('FailedCopyAttempts', [int32]0x00000008)
[void]$EnumBuilder.DefineLiteral('FatalError', [int32]0x000000010)
$EnumBuilder.SetCustomAttribute(
[FlagsAttribute].GetConstructor([Type]::EmptyTypes),
@()
)
[void]$EnumBuilder.CreateType()
# https://pshirwin.wordpress.com/2016/03/18/robocopy-exitcodes-the-powershell-way/
#region Enum
$EnumBuilder = $ModuleBuilder.DefineEnum($TypeName, 'Public', [int32])
[void]$EnumBuilder.DefineLiteral('NoChange', [int32]0x00000000)
[void]$EnumBuilder.DefineLiteral('OKCopy', [int32]0x00000001)
[void]$EnumBuilder.DefineLiteral('ExtraFiles', [int32]0x00000002)
[void]$EnumBuilder.DefineLiteral('MismatchedFilesFolders', [int32]0x00000004)
[void]$EnumBuilder.DefineLiteral('FailedCopyAttempts', [int32]0x00000008)
[void]$EnumBuilder.DefineLiteral('FatalError', [int32]0x000000010)
$EnumBuilder.SetCustomAttribute(
[FlagsAttribute].GetConstructor([Type]::EmptyTypes),
@()
)
[void]$EnumBuilder.CreateType()
#endregion Enum
} catch {
throw $_
Expand Down

0 comments on commit e7cd226

Please sign in to comment.