search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Getting MSSQL Server Roles via PowerShell
Posted in Windows Powershell | No Comment | 1,000 views | 04/03/2016 14:19

You can get detailed info about SQL Server Role properties via following code:

1
2
3
4
5
6
7
8
9
10
11
$MSSQLServerManager = New-Object 'Microsoft.SqlServer.Management.SMO.Server'
 
# Get SQL Roles
$MSSQLRoles = @($MSSQLServerManager.Roles)[0]
 
# Get SQL Logins Properties
$HostSQLRoleName = $MSSQLRoles.Name;
$HostSQLOwner = $MSSQLRoles.Owner;
$HostSQLIsFixedRole = $MSSQLRoles.IsFixedRole;
$HostSQLCreateDate = $MSSQLRoles.DateCreated;
$HostSQLDateLastModified = $MSSQLRoles.DateModified;

You can also check other properties by listing all properties of $MSSQLRoles.



Leave a Reply