scriptz
asked on
modify an existing powershell script to add a sep query
I am trying to add another search to list sep version to this existing script that currently list the servers name ip address, os version, servicePack, Uptime, lastboot. Â I need it to display the productversion listed in the registry hklm "Software\SYMANTEC\Symante c Endpoint Protection\SMC" for each server. Â
Param ([switch]$NoWarning,[switc h]$Debug)
Â
If ($Debug) {
  #enable debug messages if -debug is specified
  $debugPreference="Continue "
}
Â
If ($NoWarning) {
  #turn off warning messages
  $WarningPreference="Silent lyContinue "
}
Â
function Ping-Host {
 Param([string]$computernam e=$(Throw "You must specify a computername."))
 Â
 Write-Debug "In Ping-Host function"
 Â
 $query="Select * from Win32_PingStatus where address='$computername'"
 Â
 $wmi=Get-WmiObject -query $query
 write $wmi
}
Â
function Get-OS {
 Param([string]$computernam e=$(Throw "You must specify a computername."))
 Write-Debug "In Get-OS Function"
 $wmi=Get-WmiObject Win32_OperatingSystem -computername $computername -ea stop
 Â
 write $wmi
Â
}
Â
Â
#Generated Form Function
function GenerateForm {
Â
#region Import the Assemblies
Write-Debug "Loading Assemblies"
[reflection.assembly]::loa dwithparti alname("Sy stem.Drawi ng") | Out-Null
[reflection.assembly]::loa dwithparti alname("Sy stem.Windo ws.Forms") | Out-Null
#endregion
Â
#region Generated Form Objects
Write-Debug "Creating form objects"
$form1 = New-Object System.Windows.Forms.Form
$lblRefreshInterval = New-Object System.Windows.Forms.Label
$numInterval = New-Object System.Windows.Forms.Numer icUpDown
$btnQuit = New-Object System.Windows.Forms.Butto n
$btnGo = New-Object System.Windows.Forms.Butto n
$dataGridView = New-Object System.Windows.Forms.DataG ridView
$label2 = New-Object System.Windows.Forms.Label
$statusBar = New-Object System.Windows.Forms.Statu sBar
$txtComputerList = New-Object System.Windows.Forms.TextB ox
$timer1 = New-Object System.Windows.Forms.Timer
#endregion Generated Form Objects
Â
#------------------------- ---------- ---------- -
#Generated Event Script Blocks
#------------------------- ---------- ---------- -
Â
$LaunchCompMgmt= Â
{
  #only launch computer management if a cell in the Computername Â
  #column was selected.
  $c=$dataGridView.CurrentCe ll.columni ndex
  $colHeader=$dataGridView.c olumns[$c] .name
  if ($colHeader -eq "Computername") {
    $computer=$dataGridView.Cu rrentCell. Value
    Write-Debug ("Launch computer management for {0}" -f $computer.toUpper())
    compmgmt.msc /computer:$computer
  }
} #end Launch Computer Management script block
Â
$GetStatus= Â
{
Â
 Trap {
    Write-Debug "Error trapped in GetStatus script block"
    Write-Warning $_.Exception.message
    Continue
  }
  Â
  #stop the timer while data is refreshed
  Write-Debug "Stop the timer"
  $timer1.stop()
Â
  Write-Debug ("Getting content from {0}" -f $txtComputerlist.Text)
  if ($computers) {Clear-Variable computers}
  Â
  #clear the table
  $dataGridView.DataSource=$ Null
  Â
  $computers=Get-Content $txtComputerList.Text -ea stop | sort Â
  Â
  if ($computers) {
   Â
    $statusBar.Text = ("Querying computers from {0}" -f $txtComputerList.Text)
    $form1.Refresh
    Â
    #create an array for griddata
    Write-Debug "Create `$griddata"
    $griddata=@()
    #create a custom object
    Â
    foreach ($computer in $computers) {
     Write-Debug "Pinging $computer"
     $statusBar.Text=("Pinging {0}" -f $computer.toUpper())
     Write-Debug "Creating `$obj"
     $obj=New-Object PSobject
     Write-Debug "Adding Computername property"
     $obj | Add-Member Noteproperty Computername $computer.ToUpper()
     Â
     #ping the computer
     if ($pingResult) {
      #clear PingResult if it has a left over value
      Clear-Variable pingResult
      }
     $pingResult=Ping-Host $computer
     Write-Debug "Pinged status code is $($pingResult.Statuscode)"
   Â
     if ($pingResult.StatusCode -eq 0) {
       Â
        $obj | Add-Member Noteproperty Pinged "Yes"
        Write-Debug "Adding $($pingresult.ProtocolAddr ess)"
        $obj | Add-Member Noteproperty IP $pingResult.ProtocolAddres s
       Â
        #get remaining information via WMI
        Trap {
        #define a trap to handle any WMI errors
        Write-Warning ("There was a problem with {0}" -f $computer.toUpper())
        Write-Warning $_.Exception.GetType().Ful lName
        Write-Warning $_.Exception.message
        Continue
        }
           Â
        if ($os) {
          #clear OS if it has a left over value
          Clear-Variable os
        }
        $os=Get-OS $computer
        if ($os) {
          $lastboot=$os.ConvertToDat eTime($os. lastbootup time)
          Write-Debug "Adding $lastboot"
          $uptime=((get-date) - ($os.ConvertToDateTime($os .lastbootu ptime))).t ostring()
          Write-Debug "Adding $uptime"
          $osname=$os.Caption
          Write-Debug "Adding $osname"
          $servicepack=$os.CSDVersio n
          Write-Debug "Adding $servicepack"
         Â
          $obj | Add-Member Noteproperty OS $osname
          $obj | Add-Member Noteproperty ServicePack $servicepack
          $obj | Add-Member Noteproperty Uptime $uptime
          $obj | Add-Member Noteproperty LastBoot $lastboot
        }
        else {
        Write-Debug "Setting properties to N/A"
          $obj | Add-Member Noteproperty OS "N/A"
          $obj | Add-Member Noteproperty ServicePack "N/A"
          $obj | Add-Member Noteproperty Uptime "N/A"
          $obj | Add-Member Noteproperty LastBoot "N/A"
        }
     }
     else {
        Write-Debug "Ping failed"
        Write-Debug "Setting properties to N/A"
Â
        $obj | Add-Member Noteproperty Pinged "No"
        $obj | Add-Member Noteproperty IP "N/A"
        $obj | Add-Member Noteproperty OS "N/A"
        $obj | Add-Member Noteproperty ServicePack "N/A"
        $obj | Add-Member Noteproperty Uptime "N/A"
        $obj | Add-Member Noteproperty LastBoot "N/A"
     }
    Â
      #Add the object to griddata
        Write-Debug "Adding `$obj to `$griddata"
        $griddata+=$obj
Â
    Â
    } #end foreach
    Â
    Write-Debug "Creating ArrayList"  Â
    $array= New-Object System.Collections.ArrayLi st
    Â
    Write-Debug "Adding `$griddata to `$arry"
    $array.AddRange($griddata)
    $DataGridView.DataSource = $array
    #find unpingable computer rows
    Write-Debug "Searching for non-pingable computers"
    $c=$dataGridView.RowCount
    for ($x=0;$x -lt $c;$x++) {
      for ($y=0;$y -lt $dataGridView.Rows[$x].Cel ls.Count;$ y++) {
        $value = $dataGridView.Rows[$x].Cel ls[$y].Val ue
        if ($value -eq "No") {
        #if Pinged cell = No change the row font color
        Write-Debug "Changing color on row $x"
        $dataGridView.rows[$x].Def aultCellSt yle.Foreco lor=[Syste m.Drawing. Color]::Fr omArgb(255 ,255,0,0)
        }
      }
    }
    Write-Debug "Setting status bar text"
    $statusBar.Text=("Ready. Last updated {0}" -f (Get-Date))
Â
  }
  else {
    Write-Debug "Setting status bar text"
    $statusBar.Text=("Failed to find {0}" -f $txtComputerList.text)
  }
 Â
  #set the timer interval
  $interval=$numInterval.val ue -as [int]
  Write-Debug "Interval is $interval"
  #interval must be in milliseconds
  $timer1.Interval = ($interval * 60000) #1 minute time interval
  Write-Debug ("Timer interval calculated at {0} milliseconds" -f $timer1.Interval )
  #start the timer
  Write-Debug "Starting timer"
  $timer1.Start()
  Â
  Write-Debug "Refresh form"
  $form1.Refresh()
 Â
} #End GetStatus scriptblock
Â
$Quit= Â
{
  Write-Debug "closing the form"
  $form1.Close()
} #End Quit scriptblock
Â
#------------------------- ---------- ---------- -
#region Generated Form Code
$form1.Name = 'form1'
$form1.Text = 'Display Computer Status'
$form1.DataBindings.Defaul tDataSourc eUpdateMod e = 0
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 890
$System_Drawing_Size.Heigh t = 359
$form1.ClientSize = $System_Drawing_Size
$form1.StartPosition = 1
$form1.BackColor = [System.Drawing.Color]::Fr omArgb(255 ,185,209,2 34)
Â
$lblRefreshInterval.Text = 'Refresh Interval (min)'
Â
$lblRefreshInterval.DataBi ndings.Def aultDataSo urceUpdate Mode = 0
$lblRefreshInterval.TabInd ex = 10
$lblRefreshInterval.TextAl ign = 64
#$lblRefreshInterval.Ancho r = 9
$lblRefreshInterval.Name = 'lblRefreshInterval'
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 128
$System_Drawing_Size.Heigh t = 23
$lblRefreshInterval.Size = $System_Drawing_Size
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 440
$System_Drawing_Point.Y = 28
$lblRefreshInterval.Locati on = $System_Drawing_Point
Â
$form1.Controls.Add($lblRe freshInter val)
Â
#$numInterval.Anchor = 9
$numInterval.DataBindings. DefaultDat aSourceUpd ateMode = 0
$numInterval.Name = 'numInterval'
$numInterval.Value = 10
$numInterval.TabIndex = 9
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 51
$System_Drawing_Size.Heigh t = 20
$numInterval.Size = $System_Drawing_Size
$numInterval.Maximum = 60
$numInterval.Minimum = 1
$numInterval.Increment = 2
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 575
$System_Drawing_Point.Y = 30
$numInterval.Location = $System_Drawing_Point
# $numInterval.add_ValueChan ged($GetSt atus)
Â
$form1.Controls.Add($numIn terval)
Â
Â
$btnQuit.UseVisualStyleBac kColor = $True
$btnQuit.Text = 'Close'
Â
$btnQuit.DataBindings.Defa ultDataSou rceUpdateM ode = 0
$btnQuit.TabIndex = 2
$btnQuit.Name = 'btnQuit'
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 75
$System_Drawing_Size.Heigh t = 23
$btnQuit.Size = $System_Drawing_Size
#$btnQuit.Anchor = 9
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 341
$System_Drawing_Point.Y = 30
$btnQuit.Location = $System_Drawing_Point
$btnQuit.add_Click($Quit)
Â
$form1.Controls.Add($btnQu it)
Â
Â
$btnGo.UseVisualStyleBackC olor = $True
$btnGo.Text = 'Get Status'
Â
$btnGo.DataBindings.Defaul tDataSourc eUpdateMod e = 0
$btnGo.TabIndex = 1
$btnGo.Name = 'btnGo'
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 75
$System_Drawing_Size.Heigh t = 23
$btnGo.Size = $System_Drawing_Size
#$btnGo.Anchor = 9
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 233
$System_Drawing_Point.Y = 31
$btnGo.Location = $System_Drawing_Point
$btnGo.add_Click($GetStatu s)
Â
$form1.Controls.Add($btnGo )
Â
$dataGridView.RowTemplate. DefaultCel lStyle.For eColor = [System.Drawing.Color]::Fr omArgb(255 ,0,128,0)
$dataGridView.Name = 'dataGridView'
$dataGridView.DataBindings .DefaultDa taSourceUp dateMode = 0
$dataGridView.ReadOnly = $True
$dataGridView.AllowUserToD eleteRows = $False
$dataGridView.RowHeadersVi sible = $False
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 870
$System_Drawing_Size.Heigh t = 260
$dataGridView.Size = $System_Drawing_Size
$dataGridView.TabIndex = 8
$dataGridView.Anchor = 15
$dataGridView.AutoSizeColu mnsMode = 16
Â
Â
Â
$dataGridView.AllowUserToA ddRows = $False
$dataGridView.ColumnHeader sHeightSiz eMode = 2
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 13
$System_Drawing_Point.Y = 70
$dataGridView.Location = $System_Drawing_Point
$dataGridView.AllowUserToO rderColumn s = $True
$dataGridView.add_CellCont entDoubleC lick($Laun chCompMgmt )
#$dataGridView.AutoResizeC olumns([Sy stem.Windo ws.Forms.D ataGridVie wAutoSizeC olumnsMode .AllCells] ::AllCells )
#$DataGridViewAutoSizeColu mnsMode.Al lCells
Â
$form1.Controls.Add($dataG ridView)
Â
$label2.Text = 'Enter the name and path of a text file with your list of computer names: (One name per line)'
Â
$label2.DataBindings.Defau ltDataSour ceUpdateMo de = 0
$label2.TabIndex = 7
$label2.Name = 'label2'
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 490
$System_Drawing_Size.Heigh t = 23
$label2.Size = $System_Drawing_Size
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 12
$System_Drawing_Point.Y = 7
$label2.Location = $System_Drawing_Point
Â
$form1.Controls.Add($label 2)
Â
$statusBar.Name = 'statusBar'
$statusBar.DataBindings.De faultDataS ourceUpdat eMode = 0
$statusBar.TabIndex = 4
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 428
$System_Drawing_Size.Heigh t = 22
$statusBar.Size = $System_Drawing_Size
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 0
$System_Drawing_Point.Y = 337
$statusBar.Location = $System_Drawing_Point
$statusBar.Text = 'Ready'
Â
$form1.Controls.Add($statu sBar)
Â
$txtComputerList.Text = 'c:\computers.txt'
$txtComputerList.Name = 'txtComputerList'
$txtComputerList.TabIndex = 0
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 198
$System_Drawing_Size.Heigh t = 20
$txtComputerList.Size = $System_Drawing_Size
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 13
$System_Drawing_Point.Y = 33
$txtComputerList.Location = $System_Drawing_Point
$txtComputerList.DataBindi ngs.Defaul tDataSourc eUpdateMod e = 0
Â
$form1.Controls.Add($txtCo mputerList )
Â
Â
#endregion Generated Form Code
Â
Write-Debug "Adding script block to timer"
#add the script block to execute when the timer interval expires
$timer1.add_Tick($GetStatu s)
Â
#Show the Form
Write-Debug "ShowDialog()"
$form1.ShowDialog()| Out-Null
Â
} #End Function
Â
#Call the Function
Write-Debug "Call GenerateForm"
GenerateForm
Param ([switch]$NoWarning,[switc
Â
If ($Debug) {
  #enable debug messages if -debug is specified
  $debugPreference="Continue
}
Â
If ($NoWarning) {
  #turn off warning messages
  $WarningPreference="Silent
}
Â
function Ping-Host {
 Param([string]$computernam
 Â
 Write-Debug "In Ping-Host function"
 Â
 $query="Select * from Win32_PingStatus where address='$computername'"
 Â
 $wmi=Get-WmiObject -query $query
 write $wmi
}
Â
function Get-OS {
 Param([string]$computernam
 Write-Debug "In Get-OS Function"
 $wmi=Get-WmiObject Win32_OperatingSystem -computername $computername -ea stop
 Â
 write $wmi
Â
}
Â
Â
#Generated Form Function
function GenerateForm {
Â
#region Import the Assemblies
Write-Debug "Loading Assemblies"
[reflection.assembly]::loa
[reflection.assembly]::loa
#endregion
Â
#region Generated Form Objects
Write-Debug "Creating form objects"
$form1 = New-Object System.Windows.Forms.Form
$lblRefreshInterval = New-Object System.Windows.Forms.Label
$numInterval = New-Object System.Windows.Forms.Numer
$btnQuit = New-Object System.Windows.Forms.Butto
$btnGo = New-Object System.Windows.Forms.Butto
$dataGridView = New-Object System.Windows.Forms.DataG
$label2 = New-Object System.Windows.Forms.Label
$statusBar = New-Object System.Windows.Forms.Statu
$txtComputerList = New-Object System.Windows.Forms.TextB
$timer1 = New-Object System.Windows.Forms.Timer
#endregion Generated Form Objects
Â
#-------------------------
#Generated Event Script Blocks
#-------------------------
Â
$LaunchCompMgmt= Â
{
  #only launch computer management if a cell in the Computername Â
  #column was selected.
  $c=$dataGridView.CurrentCe
  $colHeader=$dataGridView.c
  if ($colHeader -eq "Computername") {
    $computer=$dataGridView.Cu
    Write-Debug ("Launch computer management for {0}" -f $computer.toUpper())
    compmgmt.msc /computer:$computer
  }
} #end Launch Computer Management script block
Â
$GetStatus= Â
{
Â
 Trap {
    Write-Debug "Error trapped in GetStatus script block"
    Write-Warning $_.Exception.message
    Continue
  }
  Â
  #stop the timer while data is refreshed
  Write-Debug "Stop the timer"
  $timer1.stop()
Â
  Write-Debug ("Getting content from {0}" -f $txtComputerlist.Text)
  if ($computers) {Clear-Variable computers}
  Â
  #clear the table
  $dataGridView.DataSource=$
  Â
  $computers=Get-Content $txtComputerList.Text -ea stop | sort Â
  Â
  if ($computers) {
   Â
    $statusBar.Text = ("Querying computers from {0}" -f $txtComputerList.Text)
    $form1.Refresh
    Â
    #create an array for griddata
    Write-Debug "Create `$griddata"
    $griddata=@()
    #create a custom object
    Â
    foreach ($computer in $computers) {
     Write-Debug "Pinging $computer"
     $statusBar.Text=("Pinging {0}" -f $computer.toUpper())
     Write-Debug "Creating `$obj"
     $obj=New-Object PSobject
     Write-Debug "Adding Computername property"
     $obj | Add-Member Noteproperty Computername $computer.ToUpper()
     Â
     #ping the computer
     if ($pingResult) {
      #clear PingResult if it has a left over value
      Clear-Variable pingResult
      }
     $pingResult=Ping-Host $computer
     Write-Debug "Pinged status code is $($pingResult.Statuscode)"
   Â
     if ($pingResult.StatusCode -eq 0) {
       Â
        $obj | Add-Member Noteproperty Pinged "Yes"
        Write-Debug "Adding $($pingresult.ProtocolAddr
        $obj | Add-Member Noteproperty IP $pingResult.ProtocolAddres
       Â
        #get remaining information via WMI
        Trap {
        #define a trap to handle any WMI errors
        Write-Warning ("There was a problem with {0}" -f $computer.toUpper())
        Write-Warning $_.Exception.GetType().Ful
        Write-Warning $_.Exception.message
        Continue
        }
           Â
        if ($os) {
          #clear OS if it has a left over value
          Clear-Variable os
        }
        $os=Get-OS $computer
        if ($os) {
          $lastboot=$os.ConvertToDat
          Write-Debug "Adding $lastboot"
          $uptime=((get-date) - ($os.ConvertToDateTime($os
          Write-Debug "Adding $uptime"
          $osname=$os.Caption
          Write-Debug "Adding $osname"
          $servicepack=$os.CSDVersio
          Write-Debug "Adding $servicepack"
         Â
          $obj | Add-Member Noteproperty OS $osname
          $obj | Add-Member Noteproperty ServicePack $servicepack
          $obj | Add-Member Noteproperty Uptime $uptime
          $obj | Add-Member Noteproperty LastBoot $lastboot
        }
        else {
        Write-Debug "Setting properties to N/A"
          $obj | Add-Member Noteproperty OS "N/A"
          $obj | Add-Member Noteproperty ServicePack "N/A"
          $obj | Add-Member Noteproperty Uptime "N/A"
          $obj | Add-Member Noteproperty LastBoot "N/A"
        }
     }
     else {
        Write-Debug "Ping failed"
        Write-Debug "Setting properties to N/A"
Â
        $obj | Add-Member Noteproperty Pinged "No"
        $obj | Add-Member Noteproperty IP "N/A"
        $obj | Add-Member Noteproperty OS "N/A"
        $obj | Add-Member Noteproperty ServicePack "N/A"
        $obj | Add-Member Noteproperty Uptime "N/A"
        $obj | Add-Member Noteproperty LastBoot "N/A"
     }
    Â
      #Add the object to griddata
        Write-Debug "Adding `$obj to `$griddata"
        $griddata+=$obj
Â
    Â
    } #end foreach
    Â
    Write-Debug "Creating ArrayList"  Â
    $array= New-Object System.Collections.ArrayLi
    Â
    Write-Debug "Adding `$griddata to `$arry"
    $array.AddRange($griddata)
    $DataGridView.DataSource = $array
    #find unpingable computer rows
    Write-Debug "Searching for non-pingable computers"
    $c=$dataGridView.RowCount
    for ($x=0;$x -lt $c;$x++) {
      for ($y=0;$y -lt $dataGridView.Rows[$x].Cel
        $value = $dataGridView.Rows[$x].Cel
        if ($value -eq "No") {
        #if Pinged cell = No change the row font color
        Write-Debug "Changing color on row $x"
        $dataGridView.rows[$x].Def
        }
      }
    }
    Write-Debug "Setting status bar text"
    $statusBar.Text=("Ready. Last updated {0}" -f (Get-Date))
Â
  }
  else {
    Write-Debug "Setting status bar text"
    $statusBar.Text=("Failed to find {0}" -f $txtComputerList.text)
  }
 Â
  #set the timer interval
  $interval=$numInterval.val
  Write-Debug "Interval is $interval"
  #interval must be in milliseconds
  $timer1.Interval = ($interval * 60000) #1 minute time interval
  Write-Debug ("Timer interval calculated at {0} milliseconds" -f $timer1.Interval )
  #start the timer
  Write-Debug "Starting timer"
  $timer1.Start()
  Â
  Write-Debug "Refresh form"
  $form1.Refresh()
 Â
} #End GetStatus scriptblock
Â
$Quit= Â
{
  Write-Debug "closing the form"
  $form1.Close()
} #End Quit scriptblock
Â
#-------------------------
#region Generated Form Code
$form1.Name = 'form1'
$form1.Text = 'Display Computer Status'
$form1.DataBindings.Defaul
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width
$System_Drawing_Size.Heigh
$form1.ClientSize = $System_Drawing_Size
$form1.StartPosition = 1
$form1.BackColor = [System.Drawing.Color]::Fr
Â
$lblRefreshInterval.Text = 'Refresh Interval (min)'
Â
$lblRefreshInterval.DataBi
$lblRefreshInterval.TabInd
$lblRefreshInterval.TextAl
#$lblRefreshInterval.Ancho
$lblRefreshInterval.Name = 'lblRefreshInterval'
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width
$System_Drawing_Size.Heigh
$lblRefreshInterval.Size = $System_Drawing_Size
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 440
$System_Drawing_Point.Y = 28
$lblRefreshInterval.Locati
Â
$form1.Controls.Add($lblRe
Â
#$numInterval.Anchor = 9
$numInterval.DataBindings.
$numInterval.Name = 'numInterval'
$numInterval.Value = 10
$numInterval.TabIndex = 9
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width
$System_Drawing_Size.Heigh
$numInterval.Size = $System_Drawing_Size
$numInterval.Maximum = 60
$numInterval.Minimum = 1
$numInterval.Increment = 2
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 575
$System_Drawing_Point.Y = 30
$numInterval.Location = $System_Drawing_Point
# $numInterval.add_ValueChan
Â
$form1.Controls.Add($numIn
Â
Â
$btnQuit.UseVisualStyleBac
$btnQuit.Text = 'Close'
Â
$btnQuit.DataBindings.Defa
$btnQuit.TabIndex = 2
$btnQuit.Name = 'btnQuit'
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width
$System_Drawing_Size.Heigh
$btnQuit.Size = $System_Drawing_Size
#$btnQuit.Anchor = 9
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 341
$System_Drawing_Point.Y = 30
$btnQuit.Location = $System_Drawing_Point
$btnQuit.add_Click($Quit)
Â
$form1.Controls.Add($btnQu
Â
Â
$btnGo.UseVisualStyleBackC
$btnGo.Text = 'Get Status'
Â
$btnGo.DataBindings.Defaul
$btnGo.TabIndex = 1
$btnGo.Name = 'btnGo'
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width
$System_Drawing_Size.Heigh
$btnGo.Size = $System_Drawing_Size
#$btnGo.Anchor = 9
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 233
$System_Drawing_Point.Y = 31
$btnGo.Location = $System_Drawing_Point
$btnGo.add_Click($GetStatu
Â
$form1.Controls.Add($btnGo
Â
$dataGridView.RowTemplate.
$dataGridView.Name = 'dataGridView'
$dataGridView.DataBindings
$dataGridView.ReadOnly = $True
$dataGridView.AllowUserToD
$dataGridView.RowHeadersVi
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width
$System_Drawing_Size.Heigh
$dataGridView.Size = $System_Drawing_Size
$dataGridView.TabIndex = 8
$dataGridView.Anchor = 15
$dataGridView.AutoSizeColu
Â
Â
Â
$dataGridView.AllowUserToA
$dataGridView.ColumnHeader
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 13
$System_Drawing_Point.Y = 70
$dataGridView.Location = $System_Drawing_Point
$dataGridView.AllowUserToO
$dataGridView.add_CellCont
#$dataGridView.AutoResizeC
#$DataGridViewAutoSizeColu
Â
$form1.Controls.Add($dataG
Â
$label2.Text = 'Enter the name and path of a text file with your list of computer names: (One name per line)'
Â
$label2.DataBindings.Defau
$label2.TabIndex = 7
$label2.Name = 'label2'
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width
$System_Drawing_Size.Heigh
$label2.Size = $System_Drawing_Size
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 12
$System_Drawing_Point.Y = 7
$label2.Location = $System_Drawing_Point
Â
$form1.Controls.Add($label
Â
$statusBar.Name = 'statusBar'
$statusBar.DataBindings.De
$statusBar.TabIndex = 4
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width
$System_Drawing_Size.Heigh
$statusBar.Size = $System_Drawing_Size
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 0
$System_Drawing_Point.Y = 337
$statusBar.Location = $System_Drawing_Point
$statusBar.Text = 'Ready'
Â
$form1.Controls.Add($statu
Â
$txtComputerList.Text = 'c:\computers.txt'
$txtComputerList.Name = 'txtComputerList'
$txtComputerList.TabIndex = 0
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width
$System_Drawing_Size.Heigh
$txtComputerList.Size = $System_Drawing_Size
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 13
$System_Drawing_Point.Y = 33
$txtComputerList.Location = $System_Drawing_Point
$txtComputerList.DataBindi
Â
$form1.Controls.Add($txtCo
Â
Â
#endregion Generated Form Code
Â
Write-Debug "Adding script block to timer"
#add the script block to execute when the timer interval expires
$timer1.add_Tick($GetStatu
Â
#Show the Form
Write-Debug "ShowDialog()"
$form1.ShowDialog()| Out-Null
Â
} #End Function
Â
#Call the Function
Write-Debug "Call GenerateForm"
GenerateForm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
($reg.opensubkey("Software \SYMANTEC\ Symantec Endpoint Protection")).getvalue("SM C")
this will resolve the value to string
or you can variable it to $regvalue
set your script to do something that meet the desired value
if ($regvalue -eq "whatever)
{
do something
}
else
{
do something
}
this will resolve the value to string
or you can variable it to $regvalue
set your script to do something that meet the desired value
if ($regvalue -eq "whatever)
{
do something
}
else
{
do something
}
ASKER
$reg = [Microsoft.Win32.RegistryK
($reg.opensubkey("Software