Add host details (machines names) to a test file.
Compile the function
Run the function: RunningSQLServices
SQl Hunt,
2019-05-03 (first published: 2015-03-26)
Add host details (machines names) to a test file.
Compile the function
Run the function: RunningSQLServices
Function RunningSQLServices { [CmdletBinding()] Param ( [Parameter(Position=0,Mandatory=$true)][string]$filepath #Enter filename containing server names with single quotes , [Parameter(Position=1,Mandatory=$true)][string]$outfile #Enter path with single quotes (The file will be recreated if you use the same output file.) ) Process { $result=@() ForEach ($objitem in get-content $filepath) { $result += $objitem |out-file $outfile $result += get-service -ComputerName $objitem -displayname *SQL*| Where-Object {$_.status -eq "Running"}| Select-Object Machinename, Status,Name,DisplayName | format-table -auto -wrap -force } #$result | export-csv $outfile -Delimiter "|" -NoTypeInformation $result | out-file $outfile #$result | Export-CSV $outfile -Append #$result | Export-Csv -Path 'C:\service_status1.txt' -Delimiter ';' –notype #$result |export-csv -delimiter "$" -path $outfile } } ## Execute the function. RunningSQLServices 'c:\hostname.txt' 'c:\reporttab.txt'
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
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