Question : skip sections of powershell script

I am very new to powershell scripting (started today) and using tutorials and samples online I have a decent script that will populate a xls with computer specs.  I would like to have portions skipped over if the computer does not reply to pings.  Any ideas on how to do this?

Thanks in advanced.  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
#$erroractionpreference = "SilentlyContinue"

# Create a New Excel Object for storing Data

$a = New-Object -comobject Excel.Application


$b = $a.Workbooks.Add()
$c = $b.Worksheets.Item(1)

# Create the title row

$c.Cells.Item(1,1) = "Machine Name" 
$c.Cells.Item(1,2) = "Location"
$c.Cells.Item(1,3) = "IP Address"
$c.Cells.Item(1,4) = "Dell Service Tag"
$c.Cells.Item(1,5) = "Computer Model"
$c.Cells.Item(1,6) = "OS / SP"
$c.Cells.Item(1,7) = "CPU Type"
$c.Cells.Item(1,8) = "CPU Speed"
$c.Cells.Item(1,9) = "RAM"
$c.Cells.Item(1,10) = "HD Free"


$d = $c.UsedRange
$d.Interior.ColorIndex = 23
$d.Font.ColorIndex = 2
$d.Font.Bold = $True

$intRow = 2

# read list of computer names or IP addresses into array
$colComputers = get-content "list.txt"

# process all of below once for each hostname or IP address
foreach ($strComputer in $colComputers)
{

write-host ""
write-host "Attempting to ping "  $strComputer
# Now ping the system
$ping = get-wmiobject -Query "select * from win32_pingstatus where Address='$strcomputer'"
# Display Results
if ($ping.statuscode -eq 0) {
"Response time: {0}ms" -f $ping.responsetime
}
else {
"no response"

}






    $obj32NIC = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -namespace "root\CIMV2" -computername $strComputer -Filter "IPEnabled = 'True'"
    $col32OS =Get-WmiObject -class Win32_OperatingSystem -computername $Strcomputer
    $col32System = get-wmiobject -class "Win32_ComputerSystem" -namespace "root\CIMV2" -computername $strcomputer
    $col32Bios = Get-WmiObject -Class Win32_BIOS -namespace "root\CIMV2" -computername $strComputer
    $col32Proc = get-wmiobject -class "Win32_Processor" -namespace "root\CIMV2" -computername $strComputer

 write-host "Gathering Info for " $strComputer
 foreach ($objNACItem in $obj32NIC)
        {
         $c.Cells.Item($intRow, 1) = $objNACItem.DNSHostname
         $c.Cells.Item($intRow, 3) = $objNACItem.IPAddress
        }
        
 foreach ($objBiosItem in $col32Bios)
        {
        $c.Cells.Item($intRow, 4) = $objBiosItem.SerialNumber
        } 
        
 foreach ($objSYSitem in $col32System)
        {
         $c.Cells.Item($intRow, 5) = $objSYSitem.Manufacturer + $objSysItem.model
         $c.Cells.Item($intRow, 9) = "GB: " + $objSYSitem.TotalPhysicalMemory/1000000000
  
        } 
        
 foreach ($objOSitem in $col32OS)
        {
        
        if ($col32System.domainrole = 1 -or 0)
           {
            switch ($objOSitem.Version)
                {
                 "5.0.2195"{$c.Cells.Item($intRow, 6) = "2000 " + $objOSitem.ServicePackMajorVersion}            
                 "5.1.2600"{if ($objOSitem.ServicePackMajorVersion -gt 0)
                               {$c.Cells.Item($intRow, 6) = "Win XP SP " + $objOSitem.ServicePackMajorVersion }
                               else 
                                {$c.Cells.Item($intRow, 6) = "Win XP"} 
                            }    
                 "6.1.7600"{if ($objOSitem.ServicePackMajorVersion -gt 0)
                               {$c.Cells.Item($intRow, 6) = "Win Vista SP " + $objOSitem.ServicePackMajorVersion }
                               else 
                                {$c.Cells.Item($intRow, 6) = "Win Vista"} 
                            } 
                 "6.1.7600"{if ($objOSitem.ServicePackMajorVersion -gt 0)
                               {$c.Cells.Item($intRow, 6) = "Win 7 SP " + $objOSitem.ServicePackMajorVersion }
                               else 
                                {$c.Cells.Item($intRow, 6) = "Win 7"} 
                            }            
                 }
           }
        
        
         #$c.Cells.Item($intRow, 6) = $objOSitem.Version
         #$c.Cells.Item($intRow, 26) = $objOSitem.ServicePackMajorVersion
        }      
                         
 foreach ($objProcItem in $col32Proc)
        {
         $c.Cells.Item($intRow, 7) = $objProcItem.Name + " X " + $objSysitem.NumberOfProcessors  
         $c.Cells.Item($intRow, 8) = $objProcItem.CurrentClockSpeed
        }  
        
    
    $intRow = $intRow + 1
}


$d = $c.UsedRange
$d.EntireColumn.AutoFit()
$a.visible = $True

Answer : skip sections of powershell script

It is there in your code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
# Now ping the system  
$ping = get-wmiobject -Query "select * from win32_pingstatus where Address='$strcomputer'"  
# Display Results  
if ($ping.statuscode -eq 0) {  
"Response time: {0}ms" -f $ping.responsetime  
##################################
# Here is the part that will run if computer could be pinged
##################################
}  
else {  
"no response"  
##################################
# This is the part that will run if computer could not be pinged
##################################

}  

##################################
# And this is the part that will run anyway
##################################
Random Solutions  
 
programming4us programming4us