Find Jobs
Hire Freelancers

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

$30-250 USD

Teljesítve
Kiadva ekkor: majdnem 6 évvel ezelőtt

$30-250 USD

Teljesítéskor fizetve
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
Projektazonosító: 16637004

A projektről

5 ajánlat
Távolról teljesíthető projekt
Aktiválva: 6 évvel ezelőtt

Szeretne pénzt keresni?

A Freelancer oldalán történő árajánlatadás előnyei

Határozzon meg költségvetést és időkeretet
Kapja meg fizetését a munkáért
Vázolja ajánlatát
Ingyen regisztrálhat és adhat árajánlatot munkákra
Neki odaítélve:
Felhasználó avatár
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 2 napon belül
5,0 (5 értékelés)
3,0
3,0
5 szabadúszó adott átlagosan $100 USD összegű árajánlatot erre a munkára
Felhasználó avatár
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 5 napon belül
5,0 (8 értékelés)
3,6
3,6
Felhasználó avatár
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 1 napon belül
0,0 (0 értékelés)
0,0
0,0
Felhasználó avatár
A proposal has not yet been provided
$35 USD 1 napon belül
0,0 (0 értékelés)
0,0
0,0

Az ügyfélről

UNITED STATES zászlója
Pensacola, United States
0,0
0
Fizetési mód hitelesítve
Tagság kezdete: ápr. 5, 2018

Ügyfél-hitelesítés

Köszönjük! E-mailben elküldtük a linket, melyen átveheti ajándék egyenlegét.
E-mailje elküldése során valami hiba történt. Kérjük, próbálja újra.
Regisztrált Felhasználók Összes Közzétett Munka
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Előnézet betöltése
Hozzáférést adott a helymeghatározáshoz.
Belépési munkamenete lejárt, és kijelentkeztettük. Kérjük, lépjen be újra.