I'm learning Powershell scripting in my class and for my assignment I need to use a hashtable and send the information in an email. (I do not have to send the email, It just needs to work, I'd never send this stuff though an email) But when ever I do test the script the email I get shows System.Collections.Hastable.Computer_Name, ect. How do I get the values to show in the email? Thank you.
Here is my script:
$exists=Test-Path C:\Users\user\Desktop\cred.xml
if($exists -eq $false){
Get-Credential|Export-Clixml C:\Users\user\Desktop\cred.xml}
$cred=Import-clixml -Path C:\Users\user\Desktop\cred.xml
$hash = @{ID = 1; Computer_Name = $env:COMPUTERNAME; Ip_Address = (((Test-Connection $env:computername -Count 1).ipv4address).ipaddresstostring); RAM = ((systeminfo | Select-String 'Total Physical Memory:').ToString().Split(':')[1].Trim()); BIOS_Version = ((systeminfo | Select-String 'BIOS Version:').ToString().Split(':')[1].Trim())}
$mailMessage =@{
from="user@keyman .com"
to="user@keyman .com"
subject="Computer Information"
body="
Computer Name - $hash.Computer_Name
Ip Address - $hash.Ip_Address
RAM - $hash.RAM
BIOS Version - $hash.BIOS_Version"
smtpserver="smtp.office365.com"
port="587"
usessl=$true
credential=$cred}
Send-MailMessage @mailMessage