Infrastructure at your Service

Tag

PowerShell Archives - Blog dbi services

Nathan Courtine

Automate CNOs and VCOs for SQL Server AAG

By | SQL Server | 2 Comments

During the installation of a new SQL Server environment in a Project, we wanted to automate the whole process deployment and configuration when installing a new SQL Server Always On Availability Group (AAG). This installation requires to prestage cluster computer objects in Active Directory Domain Services, called Cluster Name Objects (CNOs) and Virutal Computer Objects (VCOs). For more information on the prestage process, please read this Microsoft article. In this blog, we will see how…

Read More
Steven Naudet

Validate your SQL Server infrastructure with dbachecks

By | Database Administration & Monitoring, SQL Server | 3 Comments

Introduction In this blog post, I’ll do an introduction to the PowerShell module dbachecks. dbachecks uses Pester and dbatools to validate your SQL Server infrastructure. With very minimal configuration you can check that your infrastructure is configured following standard best practices or your own policy. We will see the following topics – Prerequisites for dbachecks Installation – Introduction to Pester – Perform a Check – Manage the Configuration items – Import & Export – Output…

Read More
Steven Naudet

An Introduction to Pester – Unit Testing and Infrastructure checks in PowerShell

By | Database Administration & Monitoring | No Comments

Introduction If you never heard of it, Pester is a PowerShell module, written in PowerShell. It’s a framework for writing and running unit tests, integration tests, and also infrastructure checks as we will see in a moment. Pester is used for example to test PowerShell Core and Pester itself. In this blog post, I’ll do a short introduction to Pester with Installation and basic checks examples. Installation Pester is shipped by default with Windows 10…

Read More
Steven Naudet

SQL Server: Generating SQL script using PowerShell and Template file

By | Database Administration & Monitoring, Database management, SQL Server | No Comments

In this blog post, I will share with you a small PowerShell script I did recently. I have noticed that my customer performs a very repetitive and time-consuming task almost every day. New columns are added to tables on their business-critical database and they need to maintain SQL scripts file with all the ALTER TABLE statements for each new column. For every new column, my customer copy-pastes the following SQL Script and then change parts…

Read More
Daniel Westermann

Publishing a PowerShell script to AWS Lambda

By | AWS | No Comments

I’ve done some Lambda functions with Python in the past and it was quite easy to publish that to Lambda (by just uploading a zip file with all my code and dependencies). You might ask yourself why I want to do that with PowerShell but the reason is quite simple: There was a requirement at a customer to automatically collect all the KBs that are installed in the AWS Windows WorkSpaces for compliance reasons. Doing…

Read More
Steven Naudet

How to create an Azure SQL Database using Azure PowerShell

By | Cloud, Database Administration & Monitoring, SQL Server | No Comments

In this blog post, I’ll go through the steps to create an Azure SQL Database using Azure PowerShell. Introduction to Azure SQL Database The SQL database services provided by Microsoft on the cloud are now grouped under the name of Azure SQL. The Azure SQL family contains services that I will briefly summarize; Azure SQL Database – DBaaS (Database-as-a-Service) Azure SQL Managed Instance – PaaS (Platform-as-a-Service) SQL Server on Azure VMs – IaaS (Infrastructure-as-a-Service) In…

Read More
Steven Naudet

SQL Server: Synchronize logins on AlwaysOn replicas with dbatools

By | Database Administration & Monitoring, SQL Server | One Comment

The SQL Server environment  I worked with today has dozens of SQL Server instances using AlwaysOn Availability Groups for High Availability. When a login is created on the Primary replica of an Availability Group it is not synchronized automatically on secondary replicas. This might cause some issues after a failover (Failed logins). Since this is not done automatically by SQL Server out of the box the DBA has to perform this task. To avoid doing…

Read More
Stéphane Savorgnano

How to run Avamar backup on SQL Agent Job with PowerShell

By | Database Administration & Monitoring, Database management, SQL Server | No Comments

By one of our customer we use Avamar for the backup and restore solution. I was asked by this customer to find a solution to run Avamar backups for a group of databases on a specified instance. In fact, we currently try a database clone solution on some instances and clone’s databases must not be backed up, but the rest of the databases must be. After some discussions with my colleague I decided to use…

Read More
Steven Naudet

SQL Server: Quickly clean backup history with dbatools

By | Database Administration & Monitoring | No Comments

I just had to restore a database in production for my customer. Before doing the restore I have the habit to query the msdb.dbo.backupset table to get an overview of the last backups. When running my query, I felt it was taking longer than usual. So out of curiosity, I looked at the SSMS standard report “Disk Usage by Top Tables”. Here is the output. This instance contains dozens of databases in Always On Availability…

Read More
Nathan Courtine

Restore S3 Object with AWSPOWERSHELL

By | Cloud | No Comments

AWS S3 offers different Storage Classes, allowing to optimize cost among others. For instance, some classes are used for archiving purposes: S3 Glacier and S3 Glacier Deep Archive. It means the storage cost is the lowest you can obtain, but your data is not available immediately and the access cost is increased. In the case of S3 archive classes, retrieving the data is not cost-effective because this is clearly not what it is aimed for….

Read More