Tuesday, December 9, 2025

Moving multiple source Files to a New Path Using PowerShell

 Moving Files to a New Path Using PowerShell

When you need to move a large number of files from different locations into a single directory, managing them manually can be time-consuming. PowerShell makes this task simple with just a few lines of code.

In this example, we store a list of file paths inside a text file (pathlist.txt). PowerShell reads each path and moves the file to a destination folder—while also checking whether the file exists before attempting the move.

PowerShell Script

# Read file paths from text file $FilePathList = Get-Content ".\pathlist.txt" foreach ($file in $FilePathList) { if (Test-Path -Path $file) { Move-Item -Path $file -Destination "C:\destination\" ` -ErrorAction SilentlyContinue -Force } else { Write-Host "$file does not exist ***" -BackgroundColor Red } }

How it Works

  • Get-Content loads each file path from pathlist.txt.

  • Test-Path confirms whether the file actually exists.

  • Move-Item transfers the file to the destination folder.

  • Errors are suppressed using -ErrorAction SilentlyContinue.

  • Non-existent files are highlighted with a red warning message.

This simple approach helps automate bulk file moves and ensures you’re notified if any paths in your list are invalid.

Deleting Single and Bulk Collections in SCCM Using PowerShell

 

Deleting Single and Bulk Collections in SCCM Using PowerShell

Managing collections in Microsoft Configuration Manager (SCCM) is a routine task for administrators. When collections become outdated or unnecessary, removing them helps keep your environment clean and organized. Instead of manually deleting each collection one by one, PowerShell makes the process faster and easier — whether you’re deleting a single collection or hundreds at once.

In this post, we’ll look at two simple PowerShell methods for removing SCCM collections: single deletion and bulk deletion.


Deleting a Single Collection

If you want to remove just one collection, PowerShell provides a straightforward cmdlet:

Remove-CMCollection -Name $collname -Force
  • Replace $collname with the exact name of the collection you want to delete.

  • The -Force parameter ensures the command runs without asking for confirmation.

This is ideal for quick, one-off cleanup tasks.


Deleting Multiple Collections (Bulk Delete)

For larger cleanup efforts, you can automate the process by reading a list of collection names from a text file and removing them all at once.

$coll = Get-Content "C:\Collection_list.txt" foreach ($collname in $coll) { Remove-CMCollection -Name $collname -Force }

How it works:

  • Collection_list.txt contains the list of collection names, one per line.

  • PowerShell loops through each entry and removes the collection automatically.

  • This approach is perfect for retiring outdated device groups or cleaning up test collections.


Why Use PowerShell for Collection Cleanup?

  • Fast and efficient

  • Reduces manual work

  • Eliminates the risk of deleting the wrong collection

  • Ideal for large-scale or recurring maintenance


PowerShell continues to be an invaluable tool for SCCM/MECM administrators, enabling quick automation and consistent results. Whether you're removing one collection or hundreds, these scripts help keep your SCCM environment lean and well-organized.

Removing an Application Deployment in SCCM Using PowerShell

Managing deployments in Microsoft Configuration Manager (SCCM) can sometimes require quick cleanup — especially when an application is no longer needed or was deployed to the wrong collection. Instead of navigating through the SCCM console, PowerShell provides a fast and reliable way to remove deployments with a single command.

In this post, we’ll look at a simple PowerShell cmdlet that removes a specific application deployment from a collection.


The PowerShell Command

Remove-CMDeployment -ApplicationName "XXX" -CollectionName "XXX" -Force

This cmdlet targets a specific application and removes its deployment from the selected collection.


How the Command Works

  • -ApplicationName "XXX"
    Specifies the application whose deployment you want to remove. Replace this with the exact application name in SCCM.

  • -CollectionName "XXX"
    Identifies the SCCM collection from which the deployment should be removed.

  • -Force
    Executes the command without prompting for confirmation — useful for automation or scripting.


Example Use Case

If you deployed an older version of an app by mistake, you could instantly remove it:

Remove-CMDeployment -ApplicationName "7-Zip 19.00" -CollectionName "All Workstations" -Force

Within seconds, the deployment is withdrawn — no console navigation required.


Why Use PowerShell?

  • Faster than using the console

  • Great for automation and repeatable tasks

  • Reduces human error

  • Ideal for environments with many collections or frequent updates


PowerShell continues to be one of the most efficient tools for SCCM administrators. With commands like Remove-CMDeployment, managing and cleaning up deployments becomes quick, consistent, and hassle-free.

If you'd like, I can also create a longer version, add screenshots, or format this for a platform like WordPress or Medium.

How to Remove a Specific Package Deployment from a Collection Using PowerShell in Configuration Manager

Removing a Specific Package Deployment from a Collection Using PowerShell

Managing deployments in Microsoft Configuration Manager (SCCM/MECM) is easier and faster when using PowerShell. If you need to remove a package deployment from a specific collection, you can do it with a single command — no console navigation required.


PowerShell Command

To remove a deployment using the package ID and collection name, use:

Remove-CMPackageDeployment -PackageID "XXX" -CollectionName "xxx" -Force

What this does

  • -PackageID specifies the exact package you want to remove.

  • -CollectionName identifies the targeted device or user collection.

  • -Force removes the deployment without prompting for confirmation.


When to Use This Command

This is especially useful when:

  • Cleaning up old or duplicate deployments

  • Updating packages and removing older versions

  • Automating deployment maintenance tasks


Prerequisites

Make sure you:

  • Run PowerShell from the ConfigMgr Console (which loads the proper module)

  • Have permissions to modify deployments in MECM


Summary

With one simple PowerShell command, you can quickly remove a package deployment from a specific collection:

Remove-CMPackageDeployment -PackageID "XXX" -CollectionName "xxx" -Force

This approach saves time, reduces errors, and fits perfectly into automation workflows.