Script: Count your SQL Databases with PowerShell

PowerShell Related Scripting Forum
User avatar
hamid
Site Admin
Posts: 15
Joined: Mon Jun 17, 2019 2:19 pm
Contact:

Script: Count your SQL Databases with PowerShell

Postby hamid Tue Jun 18, 2019 12:29 pm

Hello Club,

Here is a quick PowerShell Script which helps you to eassily count your SQL Databases and show you the result in a simple manner.

$sqlpassword = "PASSWORD" | ConvertTo-SecureString -asPlainText -Force
$sqlusername = "USERNAME"
$sqlcredential = New-Object System.Management.Automation.PSCredential($sqlusername,$sqlpassword)
$sqllist = Get-SqlDatabase -Credential $sqlcredential -ServerInstance INSTANCE NAME
$sqllist.count


Enjoy! :geek:
Microsoft MVP: Cloud and Datacenter Management
Info@hamidsadeghpour.net

Return to “General Scripting”

Who is online

Users browsing this forum: No registered users and 1 guest