Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

Using some sort of wildcards in replacement

$
0
0

Hi,

I've got a script file to create a database as below.  It has strings like "N'S:\SQLData\" and "N'R:\SQLLogs\".  They may also look like: "N'T:\SQLData\" and "N'U:\SQLLogs\".    There are three of four combinations depending on what server the production database is on.

No matter what the drive letter in production, I want to replace them with S and L drives:

"N'S:\SQLData\" and "N'L:\SQLLogs\"

I could possbily check all the combinations and do the replacement, but is there a way to use some wildcards in the replacement, e.g. replace "N'*:\SQLData\" with "N'S:\SQLData\" and "N'*:\SQLLogs\" with "N'L:\SQLLogs\"?

Thanks.

 CREATE DATABASE MyDBCZ] ON  PRIMARY
( NAME = N'MyDBCZ', FILENAME = N'S:\SQLData\MyDBCZ.mdf' , SIZE = 1536000KB , MAXSIZE = UNLIMITED, FILEGROWTH = 204800KB )
 LOG ON
( NAME = N'MyDBCZ_log', FILENAME = N'R:\SQLLogs\MyDBCZ_log.LDF' , SIZE = 1279752KB , MAXSIZE = 2048GB , FILEGROWTH = 102400KB )
 COLLATE Latin1_General_CI_AS


Viewing all articles
Browse latest Browse all 8583

Trending Articles