Hi,
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:
https://learn.microsoft.com/en-us/powershell/module/sqlserver/invoke-sqlcmd?view=sqlserver-ps
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 Install-Module sqlserver