Useful Powershell commands

1. Check if Machine Is Domain Joined (Get-WmiObject Win32_ComputerSystem).PartOfDomain 2. View SPNs for a SQL Server Service Account setspn -L domain\sqlsvcaccount 3. Register an SPN for SQL Server setspn -S MSSQLSvc domain\sqlsvcaccount 4. Create a gMSA Account (Domain Admin) New-ADServiceAccount…

Monitor Availability Group (including DAG)

SELECT name, db_name(database_id),replica_server_name,endpoint_url,availability_mode_desc,failover_mode_desc,seeding_mode_desc,backup_priority,cluster_type_desc,required_synchronized_secondaries_to_commit,is_local,is_distributed,is_primary_replica,synchronization_health_desc,synchronization_state_desc,recovery_lsn,last_hardened_lsn,last_hardened_time,secondary_lag_secondsFROM sys.availability_replicas AS arINNER JOINsys.availability_groups AS agON ar.group_id = ag.group_idINNER JOINsys.dm_hadr_database_replica_states AS rsON ar.group_id = rs.group_idAND ar.replica_id = rs.replica_idORDER BY name;

How to enable STATSPACK

Statspack is a tool available from Oracle 8. It is still an option for gathering workload statistics, if diagnostics pack is not available. Standard Editions of Oracle do not support Diagnostic pack as it is an addon of Enterprise Edition.…

Add Disk to ASM

Keep in mind that if normal or extended redundancy are used then additional disk must be added in each filegroup by using FAILGROUP clause.

Tablespace Usage

select df.tablespace_name “Tablespace”,nvl(totalusedspace,0) “Used MB”,(df.totalspace – nvl(tu.totalusedspace,0)) “Free MB”, df.actualspace as “Actual File Space”,df.totalspace “Total MB”,round(100 * ( (nvl(tu.totalusedspace,0))/ df.totalspace),2) “Pct. Used”,round(100 * ( (df.totalspace – nvl(tu.totalusedspace,0))/ df.totalspace),2)“Pct. Free”from(select tablespace_name,round(sum(decode(autoextensible,’YES’,maxbytes,’NO’,bytes)) / 1048576) TotalSpace, round (sum(bytes)/1048576) ActualSpacefrom dba_data_filesgroup by tablespace_name) df,(select…

Check errors in Azure PostgreSQL

// Author: Microsoft Azure// Display name: Find Errors// Description: Search for errors in the last 6 hours.// Categories: Workloads// Resource types: Azure Database for PostgreSQL servers// Topic: Errors AzureDiagnostics| where TimeGenerated > ago(6h)| where Category == “PostgreSQLLogs”| where errorLevel_s contains…