Search code examples
windowsbatch-filetelnet

Script to get Windows version and send it by email


I want to monitor version of Windows on all computers in a domain. So I want to create a .bat file that get the local Windows version and if possible send it via email using telnet command.

I never wrote a script in Windows. So it's difficult for me to start in this area. So any help will be appreciated.


Solution

  •  for /f "skip=3 delims=\" %%A in ('net view ^| findstr /v /C:"The command completed successfully"') do Echo %%A
    

    Will give you a list of computernames. Put it in a file.

     for /f "skip=3 delims=\" %%A in ('net view ^| findstr /v /C:"The command completed successfully"') do Echo %%A >> Computername.txt
    

    Then type to do turned on computers

     wmic /node:@"Computername.txt" os get version /format:csv