Numerous fixes + a new command
+= ConvertTo-Zip - autodetects unrar, prefers it on 7-zip - resolves issues with some RAR extraction methods 7-zip does not support += Invoke-ExpressionEx - Added suppot for -WhatIf switch ++ Move-3Way - folder content comparative duplication was written to normalize a comics media folder == Moved aliases to base, they were wrongly created in docker.
This commit is contained in:
parent
f5e1f3e9af
commit
79e85bb21d
8 changed files with 98 additions and 14 deletions
|
@ -134,6 +134,7 @@ function Invoke-ExpressionEx {
|
|||
[switch]$Force,
|
||||
[string]$Function,
|
||||
[switch]$MarshalOutput,
|
||||
[string[]]$sudoArgs,
|
||||
[Parameter(Position = 1, ValueFromRemainingArguments = $true)]
|
||||
[string[]]$expr
|
||||
)
|
||||
|
@ -157,7 +158,11 @@ function Invoke-ExpressionEx {
|
|||
if ( "$sudo_exec" -match 'not found' ) { $sudo_exec = [string]::Empty }
|
||||
}
|
||||
if ( $sudo_exec ) {
|
||||
& $sudo_exec $sudo_cmd
|
||||
if( [bool]$WhatIfPreference.IsPresent ) {
|
||||
Write-Host "What if: using sudo [$sudo_exec] to run [$sudo_cmd]"
|
||||
} else {
|
||||
& $sudo_exec "$sudoArgs" $sudo_cmd
|
||||
}
|
||||
}
|
||||
else {
|
||||
Write-Error "Didn't find a known sudo command"
|
||||
|
@ -165,7 +170,12 @@ function Invoke-ExpressionEx {
|
|||
}
|
||||
|
||||
if ( $PSVersionTable.Platform -eq 'Unix' ) {
|
||||
/usr/bin/env sudo "--preserve-env" $(Get-PowerShellPath) "-noprofile" "-EncodedCommand" $(ConvertTo-Base64 $sudo_cmd)
|
||||
if( [bool]$WhatIfPreference.IsPresent ) {
|
||||
Write-Host "What if: passing encoded command to powershell [$sudo_cmd]"
|
||||
} else {
|
||||
if( -not $sudoArgs ) { $sudoArgs = @( "--preserve-env" ) }
|
||||
/usr/bin/env sudo $sudoArgs $(Get-PowerShellPath) "-noprofile" "-EncodedCommand" $(ConvertTo-Base64 $sudo_cmd)
|
||||
}
|
||||
}
|
||||
else {
|
||||
$local:currentIdenity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
|
||||
|
@ -224,7 +234,11 @@ function Invoke-ExpressionEx {
|
|||
}
|
||||
|
||||
Write-Verbose "Perofrming the following expression in-line:`n{$($expr -join ' ')}"
|
||||
Invoke-Expression "$expr"
|
||||
if( [bool]$WhatIfPreference.IsPresent ) {
|
||||
Write-Host "What if: Invoke-ExpressionEx executing [$expr]"
|
||||
} else {
|
||||
Invoke-Expression "$expr"
|
||||
}
|
||||
}
|
||||
|
||||
function Test-IsAdmin {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue