Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Read servernames from text file and perform action for all of them

$
0
0

Hi all

I have the following code

$CheckOut =Get-EventLog-ComputerNameNameofServer-LogNameSystem|where{$_.eventID-eq1074} |ft-AutoSize-Wrap|Out-String

$today = Get-Date -format d

Send-MailMessage -SmtpServerSMTPName-Toemailadress-Fromemailadress-subject"Reboots for $today"-Body$CheckOut

This will only do the server stored in NameOfServer. How do i change the code if i have a text file with servernames and the code must run for every name in the text file and output to the body of the email. Will appreciate any any help. Thanks in advance


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>