WinDirOps

0.2.0

The **WinDirOps** module provides a comprehensive set of PowerShell functions to interact with the Windows file system, offering a simplified interface for common directory operations such as clearing, removing, and managing directories both locally and remotely. It abstracts the complexity of working with local and network file paths, handling both direct access and
The **WinDirOps** module provides a comprehensive set of PowerShell functions to interact with the Windows file system, offering a simplified interface for common directory operations such as clearing, removing, and managing directories both locally and remotely. It abstracts the complexity of working with local and network file paths, handling both direct access and remote operations via PowerShell remoting.

The module is designed to handle tasks like deleting directory contents, syncing empty directories for fast deletion, and removing directories with detailed error handling. It enables seamless interaction with the file system, whether performing maintenance tasks on local folders or managing directories across multiple remote systems.

This module can be used independently or as a dependency for higher-level file management or system configuration modules, offering flexibility and reliability in directory management operations.

---

### **Key Features:**

- **Clear directory contents (local and remote).**
- **Remove directories safely** with built-in confirmation and error handling.
- **Sync directories** for fast deletion using efficient methods like `robocopy`.
- **Handle both local and UNC paths** seamlessly, converting paths automatically for remote access.
- **Detailed status reporting** on directory operations, providing success or failure messages.

---

### **Typical Use Cases:**

- **Automating system cleanup:** Regularly clear out temporary or outdated directories, both on local machines and remote servers.
- **Managing directories during deployments:** Clear and reset build directories as part of an automated deployment or CI/CD process.
- **Remote directory management:** Delete, clear, or manage folders on remote systems without needing manual access.
- **File system maintenance:** Use **WinDirOps** to ensure file system cleanliness and order during regular system maintenance tasks.
Show more

Minimum PowerShell version

5.1

Installation Options

Copy and Paste the following command to install this package using PowerShellGet More Info

Install-Module -Name WinDirOps

Copy and Paste the following command to install this package using Microsoft.PowerShell.PSResourceGet More Info

Install-PSResource -Name WinDirOps

You can deploy this package directly to Azure Automation. Note that deploying packages with dependencies will deploy all the dependencies to Azure Automation. Learn More

Manually download the .nupkg file to your system's default download location. Note that the file won't be unpacked, and won't include any dependencies. Learn More

Owners

Copyright

(c) 2024 LarryWisherMan. All rights reserved.

Package Details

Author(s)

  • LarryWisherMan

Tags

WindowsDirectories DirectoryManagement FileSystemOperations LocalDirectories RemoteDirectories PowerShellRemoting DirectoryCleanup Automation UNCPaths FileMaintenance SystemAdministration ErrorHandling DeploymentTasks RemoteManagement WindowsManagement

Functions

Clear-Directory Clear-DirectoryContents Invoke-MirRoboCopy Remove-DirectoryByType Remove-LocalDirectory Remove-RemoteDirectory

Dependencies

Release Notes

## [0.2.0] - 2024-09-10

### Added

- Added core functions

- Updated build file for release

- Added new function `Invoke-MirRoboCopy` to wrap robocopy functionality

- Added `ShouldProcess` support to all public directory-related functions to enable
safer operations using `-WhatIf` and `-Confirm`:

 - Functions updated:
   - `Clear-Directory`
   - `Clear-DirectoryContents`
   - `Remove-LocalDirectory`
   - `Remove-RemoteDirectory`
   - `Remove-DirectoryByType`
   - `Invoke-MirRoboCopy`

- Added remote computer availability check using `Test-ComputerPing`
(see [WisherTools.Helpers](https://github.com/LarryWisherMan/WisherTools.Helpers))
for functions dealing with remote directories (`Remove-RemoteDirectory` and
`Remove-DirectoryByType`). These functions now return a `FolderDeletionResult`
indicating if the computer is offline and abort the operation if it is unreachable.

- Added enhanced error handling to return detailed failure messages, including
when a remote computer is offline or the deletion operation fails.

- Created `Invoke-RobocopyCommand` as a private wrapper for robocopy
- Created `New-FolderDeletionResult` for `FolderDeletionResult` object creation

### Changed

- Updated functions to implement `Invoke-MirRoboCopy` for faster and safer
directory content clearing using robocopy.
- Suppressed nested confirmation prompts in internal function calls by passing
`-Confirm:$false` to internal operations, preventing multiple confirmation
requests during execution.

- Improved comment-based help for all functions to clearly explain local vs.
remote operations, the role of `ShouldProcess`, and how the
remote computer checks are handled.

- updated `Remove-LocalDirectory` and `Remove-RemoteDirectory` to use new wrapper
function `New-FolderDeletionResult` for `FolderDeletionResult` object creation

FileList

Version History

Version Downloads Last updated
0.2.0 (current version) 6 9/10/2024
0.2.0-previe... 2 9/10/2024
0.2.0-previe... 2 9/9/2024
0.2.0-previe... 2 9/9/2024