# Remove-ProjectFiles

Removes specific files and folders from a project directory with safety features.

Project

PSPublishModule

Build, test, version, sign, and publish PowerShell modules with reusable PowerForge pipelines.

[View on GitHub](https://github.com/EvotecIT/PSPublishModule) [Visit Website](#) [Releases](https://github.com/EvotecIT/PSPublishModule/releases/tag/v3.0.124) [Changelog](#) [Get package](https://www.powershellgallery.com/packages/PSPublishModule/2.0.27)

Stars **48**

Forks **15**

Open issues **1**

PowerShell Gallery downloads **17,213**

Release **v3.0.195**

Language: C# Updated: 2026-11-25

Command 

**Module**

`PSPublishModule`

**Inputs**

`None`

Removes specific files and folders from a project directory with safety features.

## Syntax

```
Remove-ProjectFiles
[-BackupDirectory <String>]
[-CreateBackups]
[-DeleteMethod <RemoveItem|DotNetDelete|RecycleBin>]
[-ExcludeDirectories <String[]>]
[-ExcludePatterns <String[]>]
[-Internal]
[-MaxDepth <Int32>]
[-PassThru]
-ProjectPath <String>
[-ProjectType <Build|Logs|Html|Temp|All>]
[-Recurse]
[-Retries <Int32>]
[-ShowProgress]
[<CommonParameters>]
```

[#](#method-remove-projectfiles-string-switchparameter-projectdeletemethod-string-string-switchparameter-int32-switchparameter-string-projectcleanuptype-switchparameter-int32-switchparameter)

Parameter set: `ProjectType`

```
Remove-ProjectFiles
[-BackupDirectory <String>]
[-CreateBackups]
[-DeleteMethod <RemoveItem|DotNetDelete|RecycleBin>]
[-ExcludeDirectories <String[]>]
[-ExcludePatterns <String[]>]
-IncludePatterns <String[]>
[-Internal]
[-MaxDepth <Int32>]
[-PassThru]
-ProjectPath <String>
[-Recurse]
[-Retries <Int32>]
[-ShowProgress]
[<CommonParameters>]
```

[#](#method-remove-projectfiles-string-switchparameter-projectdeletemethod-string-string-string-switchparameter-int32-switchparameter-string-switchparameter-int32-switchparameter)

Parameter set: `Custom`

## Description

Designed for build/CI cleanup scenarios where removing generated artifacts (bin/obj, packed outputs, temporary files) should be predictable and safe. Supports -WhatIf, retries and optional backups.

## Examples

### Preview cleanup of build artifacts

```powershell
Remove-ProjectFiles -ProjectPath '.' -ProjectType Build -WhatIf
```

Shows what would be removed for the selected cleanup type.

### Remove custom patterns with backups enabled

```powershell
Remove-ProjectFiles -ProjectPath '.' -IncludePatterns 'bin','obj','*.nupkg' -CreateBackups -BackupDirectory 'C:\Backups\MyRepo'
```

Creates backups before deletion and stores them under the backup directory.

## Parameters

**-BackupDirectory String optional**

Directory where backups should be stored (optional).

**-CreateBackups SwitchParameter optional**

Create backup copies of items before deletion.

**-DeleteMethod ProjectDeleteMethod optional**

Method to use for deletion.

Possible values: `RemoveItem`, `DotNetDelete`, `RecycleBin`

**-ExcludeDirectories String[] optional**

Directory names to completely exclude from processing.

**-ExcludePatterns String[] optional**

Patterns to exclude from deletion.

**-Internal SwitchParameter optional**

Suppress console output and use verbose/warning streams instead.

**-MaxDepth Int32 optional**

Maximum recursion depth. Default is unlimited (-1).

**-PassThru SwitchParameter optional**

Return detailed results.

**-ProjectPath String required**

Path to the project directory to clean.

**-ProjectType ProjectCleanupType optionalsets: ProjectType**

Type of project cleanup to perform.

Possible values: `Build`, `Logs`, `Html`, `Temp`, `All`

**-Recurse SwitchParameter optional**

Process subdirectories recursively. Defaults to true unless explicitly specified.

**-Retries Int32 optional**

Number of retry attempts for each deletion.

**-ShowProgress SwitchParameter optional**

Display progress information during cleanup.

**-IncludePatterns String[] requiredsets: Custom**

File/folder patterns to include for deletion when using the Custom parameter set.

## Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see [about_CommonParameters](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters).

Evotec API Reference Copyright 2026 Evotec Services

<!-- PowerForge markdown artifact sha256:EF864BC6BECD4AFB655B6555ED4D9327D01CC1884559CA3FD74459F25869B614 -->
