Open Powershell in admin mode
Copy and Paste the script
Make sure you change the path of the serverlist with your valid sql server details.
Finally, Run it.
SQl Hunt,
2019-05-03 (first published: 2015-03-06)
Open Powershell in admin mode
Copy and Paste the script
Make sure you change the path of the serverlist with your valid sql server details.
Finally, Run it.
$OutputPath = "C:\Powershell\SQL Script\NO_DB_Permissions\output.txt"; $cyclecount = 1 try { foreach ($svr in get-content "C:\Powershell\serverlist.txt") { "****SERVER NAME**** : $($svr)" | out-file $OutputPath -append "----------------------------------------------------------------------" | out-file $OutputPath -append Write-Host "Processing Server: $($svr), Cycle : $($cyclecount)" -Fore Red Invoke-Sqlcmd -inputfile "C:\Powershell\SQL Script\NO_DB_Permissions\nodbpermissions.sql" -ServerInstance $svr | Out-File -filepath $OutputPath -append Write-Host "Processing completed on Server: $($svr)" -Fore Green; $cyclecount += 1 } } catch { Write-Warning "Error processing command"; $error[0]; $Exception = $Error[0].Exception } finally { $ErrorActionPrefernce = $eap }
If you have a requirement to send email to recipients with attachment, can use the script.
2019-05-03 (first published: 2016-05-17)
2,937 reads
Creates a record of all or part of a Windows PowerShell session in a text file.
2019-05-03 (first published: 2015-09-17)
1,066 reads
Using Powershell, Cleanup Older than 30 days of Files & Folder through SQL Job
2019-05-03 (first published: 2015-08-04)
1,894 reads
2019-05-03 (first published: 2015-03-29)
1,537 reads
Check all the running SQL services in different servers.
You can use the details before you start implementing SQL Patch to the servers i.e. if you want to explicitly stop the SQL Services.
2019-05-03 (first published: 2015-03-26)
1,910 reads