initialize-emptyDirectory
of the module filesystem creates an empty directory and returns the corresponding System.IO.DirectoryInfo
object. $dir
already exists, it is removed (including content) and re-created. If the directory cannot be removed, the function returns $null
$dir_obj = initialize-emptyDirectory 'P:/ath/to/directory' if ($dir -eq $null) { write-host 'Could not remove directory, possibly because it is still used by another process' } do-somethingWith $dir_obj