diff --git a/src/Microsoft.PowerShell.Commands.Management/Microsoft.PowerShell.Commands.Management.csproj b/src/Microsoft.PowerShell.Commands.Management/Microsoft.PowerShell.Commands.Management.csproj index 57c1f90e28..cd84d055c0 100644 --- a/src/Microsoft.PowerShell.Commands.Management/Microsoft.PowerShell.Commands.Management.csproj +++ b/src/Microsoft.PowerShell.Commands.Management/Microsoft.PowerShell.Commands.Management.csproj @@ -15,7 +15,6 @@ - @@ -39,7 +38,6 @@ - @@ -48,7 +46,6 @@ - diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/ClearRecycleBinCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/ClearRecycleBinCommand.cs index f07356c287..a7ec8ddefa 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/ClearRecycleBinCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/ClearRecycleBinCommand.cs @@ -10,6 +10,8 @@ using System.Management.Automation; using System.Runtime.InteropServices; using System.Text.RegularExpressions; +#if !UNIX + namespace Microsoft.PowerShell.Commands { /// @@ -224,25 +226,14 @@ namespace Microsoft.PowerShell.Commands progress.RecordType = ProgressRecordType.Processing; WriteProgress(progress); + // no need to check result as a failure is returned only if recycle bin is already empty uint result = NativeMethod.SHEmptyRecycleBin(IntPtr.Zero, drivePath, NativeMethod.RecycleFlags.SHERB_NOCONFIRMATION | NativeMethod.RecycleFlags.SHERB_NOPROGRESSUI | NativeMethod.RecycleFlags.SHERB_NOSOUND); - int lastError = Marshal.GetLastWin32Error(); - - // update the progress bar to completed progress.PercentComplete = 100; progress.RecordType = ProgressRecordType.Completed; WriteProgress(progress); - - // 0 is for a successful operation - // 203 comes up when trying to empty an already emptied recyclebin - // 18 comes up when there are no more files in the given recyclebin - if (!(lastError == 0 || lastError == 203 || lastError == 18)) - { - Win32Exception exception = new Win32Exception(lastError); - WriteError(new ErrorRecord(exception, "FailedToClearRecycleBin", ErrorCategory.InvalidOperation, "RecycleBin")); - } } } } @@ -261,3 +252,4 @@ namespace Microsoft.PowerShell.Commands internal static extern uint SHEmptyRecycleBin(IntPtr hwnd, string pszRootPath, RecycleFlags dwFlags); } } +#endif diff --git a/src/Modules/Windows/Microsoft.PowerShell.Management/Microsoft.PowerShell.Management.psd1 b/src/Modules/Windows/Microsoft.PowerShell.Management/Microsoft.PowerShell.Management.psd1 index e9c7a0a7f0..b3edf3eab7 100644 --- a/src/Modules/Windows/Microsoft.PowerShell.Management/Microsoft.PowerShell.Management.psd1 +++ b/src/Modules/Windows/Microsoft.PowerShell.Management/Microsoft.PowerShell.Management.psd1 @@ -67,5 +67,6 @@ CmdletsToExport=@("Add-Content", "Get-ComputerInfo", "Get-TimeZone", "Set-TimeZone", - "Get-HotFix") + "Get-HotFix", + "Clear-RecycleBin") } diff --git a/test/powershell/engine/Basic/DefaultCommands.Tests.ps1 b/test/powershell/engine/Basic/DefaultCommands.Tests.ps1 index 6748622587..a576f3b642 100644 --- a/test/powershell/engine/Basic/DefaultCommands.Tests.ps1 +++ b/test/powershell/engine/Basic/DefaultCommands.Tests.ps1 @@ -195,7 +195,7 @@ Describe "Verify approved aliases list" -Tags "CI" { "Cmdlet", "Clear-History", "", $($FullCLR -or $CoreWindows -or $CoreUnix), "", "", "Medium" "Cmdlet", "Clear-Item", "", $($FullCLR -or $CoreWindows -or $CoreUnix), "", "", "Medium" "Cmdlet", "Clear-ItemProperty", "", $($FullCLR -or $CoreWindows -or $CoreUnix), "", "", "Medium" -"Cmdlet", "Clear-RecycleBin", "", $($FullCLR ), "", "", "" +"Cmdlet", "Clear-RecycleBin", "", $($FullCLR -or $CoreWindows ), "", "", "High" "Cmdlet", "Clear-Variable", "", $($FullCLR -or $CoreWindows -or $CoreUnix), "", "", "Medium" "Cmdlet", "Compare-Object", "", $($FullCLR -or $CoreWindows -or $CoreUnix), "", "", "None" "Cmdlet", "Complete-Transaction", "", $($FullCLR ), "", "", ""