This is a really simple article, which provides a PowerShell script that I really need to use to run another PowerShell script into another Windows server.

So I had a server that an SSIS package was running into the catalogs but the PowerShell script in the package was in another server, so in order to run without errors, we need to call the first PowerShell script that will call the second and script and the one that you needed.

So for that we are using the Enter-PSSession function by giving the server name and the credentials to connect to it.
The documentation of this function can be found here: Enter-PSSession (Microsoft.PowerShell.Core) — PowerShell | Microsoft Docs

PowerShell script example

It’s a really simple PS1 script that can be found on my GitHub reporitory:
guimatheus92/Run-PowerShell-Script-Into-Another-Server (

I hope you enjoyed this simple solution.

This article is very simple and short, so the main goal is to delete (clean up) automatically any file from a specific folder older than any days wanted.

PowerShell script

To achieve that, you can get the script from my GitHub repository:

guimatheus92/Delete-Files-from-Folder: With this PowerShell script you can delete files from folder within a certain time period (

For the script to work, you just have to define how many days you want to filter to delete files on the line below.

# Defines how many days the files can stay in the defined directory
$limit = (Get-Date).AddDays(-7)

You also need to paste the folder path where the files are located on the line below.

# Defines the destination directory to clean files
$path = "Put your folder path here"

And that’s it! Now we can automate this task easily.

Guilherme Matheus

Mechanical Engineer Business Intelligence developer, passionate about technology, I have knowledge and experience to create a BI architecture and much more 📚.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store