infinite loop for my If Statement
infinite loop if statement
[code]
$x = 0
get-content .\input5a.txt | foreach-object {$_.split(" ") } > temp.txt #splits text file store temp file
get-content .\temp.txt | foreach-object {$total++}
$server = (get-content .\temp.txt)[$x] #store first line variable
$request = (get-content .\temp.txt)[$x+1] #store second line variable (used in if looop)
for($x; $x -le $total;$x+2)
{
if($request -eq "all")
{echo "all"}# if var2 -eq all
elseif($request -eq "bios")
{echo "bios"}
elseif($request -eq "cpu")
{echo "cpu"}
elseif($request -eq "disk")
{echo "disk"}
elseif($request -eq "network")
{echo "network"}
elseif($request -eq "os")
{echo "os"}
elseif($request -eq "sys")
{echo "sys" $x $total ;break}
else {echo "wrong"}
} #for loop
[/code]
for($x; $x -le $total;$x+2) - replace for(;$x -le $total;$x+=2)
why using temp file?
$temp = get-content .\input5a.txt | foreach-object {$_.split(" ")} $total = $temp.count $server = $temp[$x] $request = $temp[$x+1]
Windows Server > Windows PowerShell
Comments
Post a Comment