Category Archives: Powershell

PowerShell String Reverse Function

Strangely, PowerShell does not include a string reverse function.  After some googling, I wrote a simple reverse function based on regular expressions: 1 2 3 4 function Reverse-String ($inputstring) { -join[regex]::Matches($inputstring,".",’RightToLeft’) }function Reverse-String ($inputstring) { -join[regex]::Matches($inputstring,".",’RightToLeft’) }

Posted in Powershell | Comments Off on PowerShell String Reverse Function

Synchronizing Logins, Jobs, and Dependent Objects between Replicas with PowerShell

Here’s a simple PowerShell Script that I developed to synchronize logins, credentials, proxies, operators, and jobs between AlwaysOn replicas using PowerShell, dbatools, and a little bit of T-SQL.   1 2 3 4 5 6 7 8 9 10 11 … Continue reading

Posted in AlwaysOn, Powershell | Comments Off on Synchronizing Logins, Jobs, and Dependent Objects between Replicas with PowerShell

Collecting Database File Stats with PowerShell

Here is a fairly simple PowerShell script that can be used to collect database file statistics across multiple servers. My version of the script is incorporated into a scheduled SQL Agent job that runs daily. It is very useful for … Continue reading

Posted in Powershell, SQL Server | Comments Off on Collecting Database File Stats with PowerShell

Powershell file mover

Pretty simple script I wrote a while back. Moves files between two paths. For example, to sweep files from a DMZ server. Optionally renames files on the target system by appending a date code. This is to avoid name collisions. … Continue reading

Posted in Powershell, Windows OS | 1 Comment

Learning SMO & Powershell

I created a small script to collect SQL Server file utilization data into a repository.  I’m collecting the space used by the files as well as the space used internally by SQL Server.  I’m doing this across all production databases … Continue reading

Posted in Powershell, SQL Server | 1 Comment