Please provide powershell script to get database list with no FULL backup or FULL backup older than 7 days in sql server
You are correct and I had required T-SQL query , but not in PowerShell . Please help me if you have any PowerShell script to get details
According to your new information in the comment you know hw to get the information via queries.
This mean that you only need to learn how to execute queries from PowerShell.
This is done using the command Invoke-Sqlcmd
You can get more information in the relevant documentation here:
Note! This command is a utility which is part of the SqlServer Module. It is not installed by default. Therefore, you might encounter the following error message:
The term 'Invoke-Sqlcmd' is not recognized as the name of a cmdlet, function, script file, or operable program.
You can install the module using the command
This link may could give you some greater ideas about sql scripts:
Yes. You can use invoke-sqlcmd.
How to execute SQL Script using windows powershell
If the response is helpful, please click "Accept Answer" and upvote it, as this could help other community members looking for similar queries.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
I agree with the previous responses, that usage of Invoke-Sqlcmd cmdlet (part of SQLPS module) helps you with direct SQL query (with -Query param) or query saved in file (with -InputFile param).
The second option I would recommend is DBAtools PS module with Get-DBABackupHistory function - description with examples of usage are well presented on docs.dbatools.io.
17 people are following this question.