From 64b233eb8f31be422f3d81042104c51c4d8d8ffc Mon Sep 17 00:00:00 2001 From: pierre Date: Wed, 17 Jul 2024 07:56:54 +0000 Subject: [PATCH] Upload New File --- .../Refresh-Acceptance_work.ps1 | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Automated_DB_refresh/Refresh-Acceptance_work.ps1 diff --git a/Automated_DB_refresh/Refresh-Acceptance_work.ps1 b/Automated_DB_refresh/Refresh-Acceptance_work.ps1 new file mode 100644 index 0000000..c7ff46d --- /dev/null +++ b/Automated_DB_refresh/Refresh-Acceptance_work.ps1 @@ -0,0 +1,65 @@ +$ServerInstance = 'tot-2020-sql-acceptance.privatelink.03ddfc49f186.database.windows.net' + +#$DBACredential = Get-Credential -UserName pgadmin -Message "Credentials for $RestoreServiceInstance" +$password = ConvertTo-SecureString 'm#*7kx1K*N7b$IBU' -AsPlainText -Force +$DBACredential = New-Object System.Management.Automation.PSCredential ("DbRefreshUser", $password) + +$ParamInvokeSQLcmd = @{ + SqlInstance = $ServerInstance + Verbose = $true + ErrorAction = 'STOP' + +} + + +if ($DBACredential) { + $ParamInvokeSqlcmd.SqlCredential = $DBACredential +} +#$query = "SELECT name FROM sys.databases order by name" +$query = "SELECT TOP (1000) * FROM [a_rc_leu].[dbo].[tblSetting]" + + +$SqlConn = Connect-DBAInstance -SQLInstance $ServerInstance -SQLCredential $DBACredential -TrustServerCertificate + + +Write-Output "$Query" +#write-warning "Continue ?" -WarningAction Inquire +#invoke-dbaquery @ParamInvokeSQLcmd -Query $Query -Database Master -Debug + +invoke-dbaquery $SqlConn -Query $Query -Database Master + + + + + +######### + + + +$list_of_server_to_connect = [ordered]@{ + "Tot-SRVCTXDC01" = [PSCustomObject]@{ + "Name"="Tot-SRVCTXDC01.roser-total.local" + "username"="roser-total\pgeeraert" + "password"="Pr0m3th3us!!" + } +} + + +$command_to_type = hostname + +$server = 'Tot-SRVCTXDC01' + + +$pw = convertto-securestring -AsPlainText -Force -String "Pr0m3th3us!!" +$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist "roser-total\pgeeraert",$pw +$server_to_connect = $list_of_server_to_connect.$server.Name +$session = New-PSSession -ComputerName $server_to_connect -Credential $cred +Invoke-Command -Session $session -ScriptBlock { hostname } + +Invoke-Command -ComputerName Tot-SRVCTXDC01.roser-total.local -ScriptBlock { + hostname + + #get-service *push*; + } +Get-ADUser 'pierretotal' -server Tot-SRVCTXDC01.roser-total.local +