Find Jobs
Hire Freelancers

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

$30-250 USD

已完成
已发布大约 6 年前

$30-250 USD

货到付款
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: 16637004

关于此项目

5提案
远程项目
活跃6 年前

想赚点钱吗?

在Freelancer上竞价的好处

设定您的预算和时间范围
为您的工作获得报酬
简要概述您的提案
免费注册和竞标工作
颁发给:
用户头像
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天之内
5.0 (5条评论)
3.0
3.0
5威客以平均价$100 USD来参与此工作竞价
用户头像
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天之内
5.0 (8条评论)
3.6
3.6
用户头像
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天之内
0.0 (0条评论)
0.0
0.0
用户头像
A proposal has not yet been provided
$35 USD 在1天之内
0.0 (0条评论)
0.0
0.0

关于客户

UNITED STATES的国旗
Pensacola, United States
0.0
0
付款方式已验证
会员自4月 5, 2018起

客户认证

谢谢!我们已通过电子邮件向您发送了索取免费积分的链接。
发送电子邮件时出现问题。请再试一次。
已注册用户 发布工作总数
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
加载预览
授予地理位置权限。
您的登录会话已过期而且您已经登出,请再次登录。