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

Need some help with script

$
0
0

Hi Guys,

I created a script and im having some issues getting it to work.  Need your advice on this. 

$servers = get-QADComputer -computerRole 'DomainController' | Select Name
$report = @()
foreach ($server in $servers)
{
 if ((Test-Connection -ComputerName $server.Name -Quiet) -eq $false)
{
$serverObj = New-Object PSObject
$serverObj | Add-Member NoteProperty -Name "ServerName" -Value $Server.Name

$serverObj | Add-Member NoteProperty -Name "Error Details" -Value ($($serverObj."Error Details") + $string) -Force
$report = $report += $serverObj
}
$body = $report | ConvertTo-Html -head $a
}
else
{
$body = "All Domain Controllers are UP"
}

Error:

The term 'else' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelli
ng of the name, or if a path was included, verify that the path is correct and try again.

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles