I'm trying to retrieve DHCP server names and Leases using this script. But when I execute this section of the script of receive the following error message:
Pwershell> C:\PowerShell\DHCPLease.ps1
At C:\PowerShell\DHCPLease.ps1:287 char:25
+ $line = $AllScopes[$i] (Read-Host " ").Split(",")
+ ~
Unexpected token '(' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
Here is the part of the script that is failing
#region Get all Scopes in the Server
# Run the Command in the Show Scopes var
$AllScopes=Invoke-Expression$ShowScopes
# Go over all the Results, start from index 5 and finish in last index -3
for($i=5;$i-lt$AllScopes.Length-3;$i++)
{
# Split the line and get the strings
$line=$AllScopes[$i](Read-Host"").Split(",") - This is the line I receive the error
$Scope.Address+=Check-Empty$line[0]
$Scope.Mask+=Check-Empty$line[1]
$Scope.State+=Check-Empty$line[2]
# Line 3 and 4 represent the Name and Comment of the Scope
# If the name is empty, try taking the comment
If(Check-Empty$line[3]-eq"-") {
$Scope.Name+=Check-Empty$line[4]
}
else{$Scope.Name+=Check-Empty$line[3]}
}