Infrastructure at your Service

Tag

PowerShell Archives - Blog dbi services

Stéphane Savorgnano

Automate restore from Rubrik with PowerShell (part 2)

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

As promised during my last Rubrik blog post I’m writing a second one to explain how to: log your different steps in a file add an integrity check after the restore and also improve my first scripting I will start by the end and improve my first scripts by creating functions for each step of the process. With Rubrik you can have multiple appliances (servers), it means that each server/instance of you SQL Server environment…

Read More
Stéphane Savorgnano

Automate restore from Rubrik with PowerShell

By | Database Administration & Monitoring | No Comments

One of our customer uses Rubrik as a solution to recover, manage, and secure all their data. In this context, Rubrik is used to backup and restore all the SQL Server instances. We need to run restore tests in this validated environment every year. To do so we decide to create a PowerShell script to automate the restore of all user databases from a source instance (a production one) to a destination instance (a test…

Read More
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 | 4 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