Resolve SID to domain account

There are reasons you need to resolve SID. You can do it by powershell:

 

 

DBATools Get-DbaDatabase] Failure | The certificate chain was issued by an authority that is not trusted.

If  you get the error:

Get-DbaDatabase] Failure | The certificate chain was issued by an authority that is not trusted.

You can set in dbatools:

 

or

 

dbatools sql The certificate chain was issued by an authority that is not trusted.
dbatools sql The certificate chain was issued by an authority that is not trusted.

Docker build

 

Some usefull  docker command  in powershell windows :

Prerequisite: Visual Studio Code Remote Development Extension Pack

 

Replace a MS SQL Database in AlwaysOn AG with DBATools

There is a database in AG and you need to drop it and restore from backup (which is sometimes a transition from developer to prod )
You don’t need any prerequisite for cluster nodes and AG names.
The script find the instance in local windows server and find the db AG nodes and listener.
So finally you need the database name and the location of the backup folder which can be an Ola backup solution folder.

Send email if performance monitor counter value average is high

Do you need an alert for CPU, for network?
Here is an example for one network card.
You can put in a ps1 file and run it from task scheduler.
You should set the email and SMTP addresses:

SQL AO AG failover in cluster group and check the synchronization status

Get info from Cluster:

Failover general example, you can use Invoke-DbaAgFailover for SQL server:

DBATools makes your life happy, you can find the SQL server instances and you can failover them.

To find  all of the SQL instances in a cluster server . To Check AG before and after the failover, and failover the SQL Server AO AG :


 

if you have to wait a lot for synchronization you can check how many servers are synchronized.


 

 

Get the subfolder sizes in a folder with PowerShell

List the subfolder sizes in a folder

 

Result sample:

 

Find old files in subfoders – older than 30 days with PowerShell

Find old files recursively with powershell script:

 

Find the oldest file:

 

 

 

Virtuális szerverek ip címei

Gyakori eset, hogy a laptop hurcolásával más és más ip címet kapnak a virtuális szervereink. Host gépen az alábbi powershell paranccsal tudjuk kiíratni a guest gépek ip címeit: