Find Jobs
Hire Freelancers

Powershell script to read in database names and create 3 text files

$30-250 USD

Terminado
Publicado hace casi 6 años

$30-250 USD

Pagado a la entrega
Need a powershell script as described below that can ingest a list of database names, then output 3 text files. Just needs to be able to read the file in from the local working directory and output the 3 new text files to the same local working dirctory 1)take input from a text list containing a list of database names: Databasenumber1 Databasenumber2 Databasenumber3 read the database names from the text file and output to a new text file, each database name needs 2 lines as shown below: Backup-SqlDatabase -Database "Databasenumber1" -BackupFile "\\sqlserver1\sharetest\[login to view URL]" -ServerInstance "sqlserver1" Backup-SqlDatabase -Database "Databasenumber1" -BackupAction "Log" -BackupFile "\\sqlserver\sharetest\[login to view URL]" -ServerInstance "sqlserver1" Backup-SqlDatabase -Database "Databasenumber2" -BackupFile "\\sqlserver1\sharetest\[login to view URL]" -ServerInstance "sqlserver1" Backup-SqlDatabase -Database "Databasenumber2" -BackupAction "Log" -BackupFile "\\sqlserver\sharetest\[login to view URL]" -ServerInstance "sqlserver1" Backup-SqlDatabase -Database "Databasenumber3" -BackupFile "\\sqlserver1\sharetest\[login to view URL]" -ServerInstance "sqlserver1" Backup-SqlDatabase -Database "Databasenumber3" -BackupAction "Log" -BackupFile "\\sqlserver\sharetest\[login to view URL]" -ServerInstance "sqlserver1" Then also need to read in the same source text list containing the database names and output another file with this content: EXECUTE AS login='USERNAME; RESTORE DATABASE Databasenumber1 FROM DISK = '\\sqlserver1\sharetest\[login to view URL]' WITH NORECOVERY; REVERT; GO RESTORE LOG Databasenumber1 FROM DISK = '\\sqlserver1\sharetest\[login to view URL]' WITH NORECOVERY, FILE = 1 GO EXECUTE AS login='USERNAME; RESTORE DATABASE Databasenumber2 FROM DISK = '\\sqlserver1\sharetest\[login to view URL]' WITH NORECOVERY; REVERT; GO RESTORE LOG Databasenumber2 FROM DISK = '\\sqlserver1\sharetest\[login to view URL]' WITH NORECOVERY, FILE = 1 GO EXECUTE AS login='USERNAME; RESTORE DATABASE Databasenumber3 FROM DISK = '\\sqlserver1\sharetest\[login to view URL]' WITH NORECOVERY; REVERT; GO RESTORE LOG Databasenumber2 FROM DISK = '\\sqlserver3\sharetest\[login to view URL]' WITH NORECOVERY, FILE = 1 GO 3rd text file output, section below for each of the database names from the original list: USE [master] GO ALTER AVAILABILITY GROUP [AGGROUP1] ADD DATABASE [Databasenumber1]; GO :ConnectDB2 begin try declare @conn bit declare @count int declare @replica_id uniqueidentifier declare @group_id uniqueidentifier set @conn = 0 set @count = 30 -- wait for 5 minutes if (serverproperty('IsHadrEnabled') = 1) and (isnull((select member_state from master.sys.dm_hadr_cluster_members where upper(member_name COLLATE Latin1_General_CI_AS) = upper(cast(serverproperty('ComputerNamePhysicalNetBIOS') as nvarchar(256)) COLLATE Latin1_General_CI_AS)), 0) <> 0) and (isnull((select state from master.sys.database_mirroring_endpoints), 1) = 0) begin select @group_id = ags.group_id from master.sys.availability_groups as ags where name = N'AGGROUP1' select @replica_id = replicas.replica_id from master.sys.availability_replicas as replicas where upper(replicas.replica_server_name COLLATE Latin1_General_CI_AS) = upper(@@SERVERNAME COLLATE Latin1_General_CI_AS) and group_id = @group_id while @conn <> 1 and @count > 0 begin set @conn = isnull((select connected_state from master.sys.dm_hadr_availability_replica_states as states where states.replica_id = @replica_id), 1) if @conn = 1 begin -- exit loop when the replica is connected, or if the query cannot find the replica status break end waitfor delay '00:00:10' set @count = @count - 1 end end end try begin catch -- If the wait loop fails, do not stop execution of the alter database statement end catch ALTER DATABASE [Databasenumber1] SET HADR AVAILABILITY GROUP = [AGGROUP1]; GO
ID del proyecto: 16637004

Información sobre el proyecto

5 propuestas
Proyecto remoto
Activo hace 6 años

¿Buscas ganar dinero?

Beneficios de presentar ofertas en Freelancer

Fija tu plazo y presupuesto
Cobra por tu trabajo
Describe tu propuesta
Es gratis registrarse y presentar ofertas en los trabajos
Adjudicado a:
Avatar del usuario
Hi there! My name is Douglas and I have been working as an Automation Developer for the last 5 years. I mainly develop using Powershell scripts and I what you need is basically what I do on a daily basis Anyway, let me ask you a few questions about your project: - What would be the deadline to deliver this project? - Do you need this ASAP or it can wait for 2 days as I have set in my bid? - What PowerShell version are you going to execute this script on? You can check the version by running the following on the PowerShell console: $PSVersionTable I'm looking forward for your reply and I really hope that we can work together on this project! Have a good one sir!
$90 USD en 2 días
5,0 (5 comentarios)
3,0
3,0
5 freelancers están ofertando un promedio de $100 USD por este trabajo
Avatar del usuario
I’m an IT professional with around 6 years of experience in Unified Communication and Virtualization technology, during this period I have worked on lots of projects in Egypt and KSA with multiple vendors such as Microsoft, HP and VMware.
$166 USD en 5 días
5,0 (8 comentarios)
3,6
3,6
Avatar del usuario
hi, I am having sound knowledge of powershell scripting and I use in my daily task for automation of things like alerts, backup jobs, scheduled tasks etc.. I can give you scrip for your need in a day. I know that I don't have lot of reviews on my profile because I have joined this platform recently and building up my profile. I assure you that you won't be disappointed if you hire me for this project. Thanks, Kush
$55 USD en 1 día
0,0 (0 comentarios)
0,0
0,0
Avatar del usuario
A proposal has not yet been provided
$35 USD en 1 día
0,0 (0 comentarios)
0,0
0,0

Sobre este cliente

Bandera de UNITED STATES
Pensacola, United States
0,0
0
Forma de pago verificada
Miembro desde abr 5, 2018

Verificación del cliente

¡Gracias! Te hemos enviado un enlace para reclamar tu crédito gratuito.
Algo salió mal al enviar tu correo electrónico. Por favor, intenta de nuevo.
Usuarios registrados Total de empleos publicados
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Cargando visualización previa
Permiso concedido para Geolocalización.
Tu sesión de acceso ha expirado y has sido desconectado. Por favor, inica sesión nuevamente.