Open Powershell in admin mode
Copy the entire script
Run it.
Note: You must have powershell 3.0 to avail Start-Transcript cmdlet.
Ensure that in your script, you have the proper database context mentioned.
SQl Hunt,
2019-05-03 (first published: 2015-09-17)
Open Powershell in admin mode
Copy the entire script
Run it.
Note: You must have powershell 3.0 to avail Start-Transcript cmdlet.
Ensure that in your script, you have the proper database context mentioned.
$filename = Get-Date -format "yyyyMMdd" $filename $path = "C:\PS_output_transcript\" + $filename +".txt" $path start-transcript $path -append write-host "test" $Server = "Your SQL Instance" #change the details accordingly. $error.Clear() invoke-sqlcmd -ServerInstance $Server -InputFile "C:\filename.sql"-verbose -ErrorAction Stop stop-transcript
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
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
Execute the function and pass only the SQL Server Name to check if the SQL Instance is available and if yes, what is the Instance Type.
2019-05-03 (first published: 2015-03-26)
1,180 reads