Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

How to list Variables for a script using Windows 7 laptop?

$
0
0

 

I admit that I am a "rookie" when it comes to PowerShell.  But I am hungry, and wanting to learn more.  I have a thick, cumbersome PowerShell reference book here, but I am struggling to learn even the basic stuff. 

So please forgive me for my following question.

I have the following script below.  My goal is to:

 

a.) list the variables in the following script;

b.) define the Purpose of the following script.

 

 

$WMI = Get-WMIObject -Computer localhost -Class Win32_DiskDrive
$body = "URGENT Disk Report `n`n"
$allclear = ""
ForEach ($Drive in $WMI){
    $body += $Drive.Caption + ": " + $Drive.Status + "`n"
    if ($Drive.Status -ne "OK") { $allclear = "N" }
  
}
$date = Get-Date
$body += "`nExecuted at " + $date

if ($allclear -eq "N") {

$EmailFrom = "EMAIL ADDRESS"
$EmailTo = "EMAIL ADDRESS"
$Subject = "ISSUE DETECTED"
$SMTPServer = "smtp.gmail.com"
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("USERNAME", "PASSWORD");
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
}
else { Write-host "No Issues Detected" }

 

 

any help would be greatly appreciated.


Viewing all articles
Browse latest Browse all 6937

Trending Articles