Category PowerShell

POWERSHELL – DELETE OLD FILES

Overview We can delete files older than X days. We can create a scheduled task to run the PowerShell script on a schedule. List Files To Delete

This code uses the Get-ChildItem and Where-Object cmdlets to search for all…

POWERSHELL – RUN INVOKE-SQLCMD

The Code

The Analysis This code is written in PowerShell to execute a stored procedure on a Microsoft SQL Server and save the results to an XML file. The first line of code invokes the Invoke-Sqlcmd cmdlet, which allows…

INSTALLING INVOKE-SQLCMD

The Invoke-Sqlcmd module is a PowerShell module that will allow you to execute T-SQL statements. In order to install the Invoke-Sqlcmd module, you will need to open PowerShell. Before installing the module, you need to set the execution policy to…