Remove-Folder
SYNOPSISโ
Remove folder and files if they exist.
SYNTAXโ
Remove-Folder [-Path] <String> [-DisableRecursion] [[-ContinueOnError] <Boolean>] [<CommonParameters>]
DESCRIPTIONโ
Remove folder and all files with or without recursion in a given path.
EXAMPLESโ
EXAMPLE 1โ
Remove-Folder -Path "$envWinDir\Downloaded Program Files"
Deletes all files and subfolders in the Windows\Downloads Program Files folder
EXAMPLE 2โ
Remove-Folder -Path "$envTemp\MyAppCache" -DisableRecursion
Deletes all files in the Temp\MyAppCache folder but does not delete any subfolders.
PARAMETERSโ
-Pathโ
Path to the folder to remove.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-DisableRecursionโ
Disables recursion while deleting.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-ContinueOnErrorโ
Continue if an error is encountered. Default is: $true.
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: True
Accept pipeline input: False
Accept wildcard characters: False
CommonParametersโ
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.