Category Archives: Powershell
As a matter fact, it is not new that dbatools is a great PowerShell module for the SQL Server DBA, and from time to time they come up with new functions that for me I just think: Why I never thought about it before?
Today I want to talk about the function Remove-DbaBackup and more specifically my customized version of it. No, I didn’t rewrite Remove-DbaBackup but rather improved to my environment. The function by itself is just great and it addresses the goal of removing the backups nicely, but at the end, the function was not doing something that I wanted. Read the rest of this entry
At work, I got to do some really interesting stuff. What I like is they really give me the freedom to try things out. Ah, and if you wanna join us, we have a position to work with me, posted here: https://grnh.se/4899e2091.
There is a saying, which I don’t exactly remember, is that a backup is only a backup if you test the restore of the same. So, I was working on creating an automated way of restoring the backups of my production databases and give me some sort of reporting around it.
So, I did that work and it is running really fine with the structure that I have. Then, I had the idea to share what I did with the community, mainly because I rely on almost all of my work to dbatools, and without them I would have more trouble/work do, to get the same results.
I shared a screenshot on twitter as you can see below.
I got a few replies from people saying that they would like to see how it is done. So, in this blog post, I’ll explain you all the steps that I had to do, to obtain this result.
There will be more than 15 sessions with all kinds of flavours, so you experiment a bit of everything 🙂 If you are in the area of Gothenburg I am sure you don’t wanna miss the event!
For me it will be a pleasure to be for my first time in Sweden and have the honor to speak there. I’m really excited! Read the rest of this entry
Those days at work I had to remove a bunch of databases from the Availability Groups and later drop them from the primary and secondary replicas. I know I could do the click, click and drop thing, but why not PowerShell? Read the rest of this entry
Last week I was helping an Application Admin to Synchronize files and folders between Source and Destination Servers. The challenge was because some folders had really long hierarchies, so you could imagine something like this.
I would say that doing this for some files it is really ok, but for my case we are talking about of 10GB of data and around 4K folders in the root level. Basically, this was the solution that I was able to come up.
The script in in the Github link below. Read the rest of this entry
I just wanted to share that I will be presenting a Lightining Talk at SQL Saturday 679 in Vienna, Austria. I will have 10 minutes to present the following session.
Title: My 5 favorite Powershell Commands!
So, if you are planning to be in Vienna for the SQL Saturday, make sure to register yourself, as there are only a few spots available. Also, if you are a DBA, I would say that you really should be attending my Lightining Talk, because the commands that I am gonna show you will save your life.. or at least make it easier.
Also, look at the Event Agenda, as there will be many other sessions in all areas of the Data Platform world.
See you in Vienna!
Passando aqui apenas para compartilhar mais um simples script PowerShell com vocês. A intenção do script é varrer uma lista de servidores de SQL Server e retornar apenas os serviços que estiverem com o status de stopped. O Script utiliza o cmdlet Get-Service. Read the rest of this entry
Meus skills de desenvolvedor são horriveis, mas me deparei com uma situação no trabalho aonde eu não poderia realizar tal tarefa manualmente, pois seria muito dificil e muito chato de realizar e partindo dessa ideia me surgiu então o PowerShell. Não preciso falar muito como o PowerShell ajuda no dia-a-dia de um Administrador de Banco de Dados, ou de qualquer outra tecnologia Microsoft.
Para SQL Server não preciso mencionar que se alguem quiser aprender sobre PowerShell o blog do Laerte Junior (Twitter|Blog) onde você encontra muita coisa boa. Voltando para o meu problema eu precisava realizar a seguinte tarefa. Read the rest of this entry
Estava configurando um ambiente de alta disponibilidade e precisa recriar todos os planos de manutenção no outro servidor, mas recriar na mão seria um trabalho árduo, então para criamos os planos no outro lado vamos as seguintes configurações.
1) Conecte na instancia do Integration Services
2) Faça o seguinte caminho: Stored Packages -> MSDB -> Maintenance Plans
Conforme mostra a figura clique sobre o pacote desejado e vá na opção “Export Package”.
3) Após isso a tela abaixo ira aparecer.
Voce deve se conectar no servidor para a qual deseja exportar os pacotes, clicar em “Package Path” e selecionar o mesmo caminho dentro de SSIS Packages.
Feito isso os jobs aparecerão para voce no outro servidor, porem um detalhe importante é que os jobs do SQL Server Agent nao sao exportados. Nada adianta ter exportado os pacotes e ter que criar os jobs tudo na mao.
Pesquisando por ai, encontrei um script em powershell feito por Enrique Puig Nouselles (SolidQ – Blog) para gerar o codigos dos jobs. Para configurar o script voce deve se atentar a dois parametros dentro do script.
1) $server = ‘localhost’ <- Servidor SQL Server
2) $outputPath = ‘C:\Temp\Script_Jobs.txt’ <- Onde deverá criar o arquivo
Feito a execução o arquivo ira aparecer onde voce predefiniu o caminho.
Agora é só executar o mesmo no outro servidor e pronto, tudo estará criado.
O script powershell pode ser baixado aqui.
Por hoje é isso, espero que tenham gostado.
MCITP SQL Server 2008