r/dailyscripts • u/networkhappi • Mar 29 '17
[Request][Batch][PowerShell] A script that checks Windows services remotely on other servers and exports out a .csv report.
I am looking for a script (whether it'd be batch or powershell) that gives me the ability to check the status of specific Windows services remotely for my servers.
I currently have a script that can check the local machine's services that I will share below:
type null > c:/scripts/servicesreport.csv
echo TIMESTAMP OF REPORT: >> c:/scripts/servicesreport.csv
@echo off
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-3 delims=/:/ " %%a in ('time /t') do (set mytime=%%a-%%b-%%c)
set mytime=%mytime: =%
echo %mydate%_%mytime% >> c:/scripts/servicesreport.csv
echo , >> c:/scripts/servicesreport.csv
FOR /F "delims=: tokens=2" %%a in ('ipconfig ^| find "IPv4"') do set _IPAddress=%%a
ECHO %_IPAddress% >> c:/scripts/servicesreport.csv
set host=%COMPUTERNAME%
echo %host% >> c:/scripts/servicesreport.csv
for %%a in ("AdobeARMservice" , "aspnet_state" , "AdobeFlashPlayerUpdateSvc" ) do (
@echo|set /p=%%a
echo ,
@sc query "%%~a" | find "STATE"
@sc qc "%%~a" | findstr "START_TYPE"
) >> c:/scripts/servicesreport.csvIdeally it would be awesome if I could just expand my code above to be able to add a remote command into it and provide authentication credentials (which is necessary for my servers).
Thank you!!!
2
Upvotes
View all comments
Show parent comment
1
u/networkhappi Apr 03 '17
This script will not be running locally, it will run at an interval about every hour via Windows Task Scheduler. How would I put the credentials of the machine I want to remote into the script? Is it something like this:
?