Hi, I'm beginning to learn powershell and would like to know how to probably write the $Body so it emails correctly.
import-module activedirectory
$Computer = Get-ADComputer -Filter * -SearchBase "CN=Computers,DC=ABC,DC=net" -Properties ipv4Address | Select Name,ipv4Address | Format-Table -HideTableHeaders | Out-String
$Count = Get-ADComputer -Filter * -SearchBase "CN=Computers,DC=ABC,DC=net" | Measure-Object | Select Count | Format-Table -HideTableHeaders | Out-String
$From="someone@someone.com"
$To="someone@someone.com"
$Subject="script test"
$SMTPServer="server1@someone.com"
$Body = "Count of computers is: $Count" +$Computer
Send-MailMessage -From $From -to $To -Subject $subject -Body $Body -SmtpServer $SMTPServer
Right now, the value for $Count is on the next line
What I would like to have it do is put that on the same line
ie "Count of computer is : 1 "
thank you
import-module activedirectory
$Computer = Get-ADComputer -Filter * -SearchBase "CN=Computers,DC=ABC,DC=net" -Properties ipv4Address | Select Name,ipv4Address | Format-Table -HideTableHeaders | Out-String
$Count = Get-ADComputer -Filter * -SearchBase "CN=Computers,DC=ABC,DC=net" | Measure-Object | Select Count | Format-Table -HideTableHeaders | Out-String
$From="someone@someone.com"
$To="someone@someone.com"
$Subject="script test"
$SMTPServer="server1@someone.com"
$Body = "Count of computers is: $Count" +$Computer
Send-MailMessage -From $From -to $To -Subject $subject -Body $Body -SmtpServer $SMTPServer
Right now, the value for $Count is on the next line
What I would like to have it do is put that on the same line
ie "Count of computer is : 1 "
thank you