Uninstall-Directory

Removes a directory, if it exists.

Syntax

Uninstall-Directory [-Path] <String> [-Recurse] [<CommonParameters>]

Description

The Uninstall-Directory function removes a directory. If the directory doesn't exist, it does nothing. If the directory has any files or sub-directories, you will be prompted to confirm the deletion of the directory and all its contents. To avoid the prompt, use the -Recurse switch.

Uninstall-Directory was added in Carbon 2.1.0.

Parameters

Name Type Description Required? Pipeline Input Default Value
Path String

The path to the directory to create.

true false
Recurse SwitchParameter

Delete the directory and everything under it.

false false False

EXAMPLE 1

Uninstall-Directory -Path 'C:\Projects\Carbon'

Demonstrates how to remove/delete a directory. In this case, the directory C:\Projects\Carbon will be deleted, if it exists.

EXAMPLE 2

Uninstall-Directory -Path 'C:\Projects\Carbon' -Recurse

Demonstrates how to remove/delete a directory that has items in it. In this case, the directory C:\Projects\Carbon and all of its files and sub-directories will be deleted, if the directory exists.