I need to get the OS version and Revision number using PowerShell on a list of remote systems.

I need the results that you get from [environment]::OSVersion.Version but on the remote systems.

when I run [environment]::OSVersion.Version 

it returns

Major Minor Build Revision

6 1 7601 65536 

the ultimate goal would be for it to look like this (where system name is the remote system I am querying.)

SystemName 6.1.7601.65536 

my current code:

```
$expectedVersion = "6.1.7601.65536"
$computer = Get-content "C:\temp\servers.txt"
foreach ($computer in $computer)
{
$a=[environment]::OSVersion.Version 
If ($a -lt $expectedVersion)
{
  Write-Host "$computer $a is NOT Patched" -ForegroundColor Red
}
Else
{
  Write-Host "$computer $a is Patched" -ForegroundColor Green
}}

```

which give me the following results:

System-01 6.1.7601.65536 is Patched

System-02 6.1.7601.65536 is Patched

System-41 6.1.7601.65536 is Patched

System-42 6.1.7601.65536 is Patched

the issue I am having is that the resulting OS version is only of the local system and not the remote systems.

I know this because it is being run from a Win 7 box against a long list of Server and only server OS which are different OS version numbers then what is showing up in the results.

what am I missing here. can you all help me tweak this to make it work against remote systems?

thanks
['https://Stackoverflow.com/questions/46006705', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1232402/']
(1) When you make a change to checkbox you need to check all checkboxes and update to textarea.

(2) function `updateAllChecked` will handle all the check and update.

(3) for check all, if it is checked, set all email checkboxes to checked and call `.change()` to trigger the change event.

```js
$("input[name=email]").change(function() {
  updateAllChecked();
});

$("input[name=addall]").change(function() {
  if (this.checked) {
    $("input[name=email]").prop('checked', true).change();
  } else {
    $("input[name=email]").prop('checked', false).change();
  }
});

function updateAllChecked() {
  $('#recipients').text('');
  $("input[name=email]").each(function() {
    if (this.checked) {
      let old_text = $('#recipients').text() ? $('#recipients').text() + ', ' : '';
      $('#recipients').text(old_text + $(this).val());
    }
  })
}
```

```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<input type="checkbox" name="email" value="email_1">email_1<br>
<input type="checkbox" name="email" value="email_2">email_2<br>
<input type="checkbox" name="email" value="email_3">email_3<br>
<input type="checkbox" name="email" value="email_4">email_4<br>
<br>
<input type="checkbox" name="addall">Add All Email<br>

<textarea id="recipients"></textarea>
```
Try something like this, using an array with a final `join()` once your array is populated. I think it's a lot cleaner:

```
    checkbox.onclick = (function(chk){
        return function() {
            var valueArray = [];
            for (var j = 0; j < checkboxes.length; j++) {
                if (checkboxes[j].checked) {
                    valueArray.push(checkboxes[j].value); //add value to array
                }
            }
            textbox.value = valueArray.join(", "); //join with comma separators
        }
    })(checkbox);

```

You could also extract the function and invoke the extracted function rather than adding the content of the function to every checkbox, but w/out seeing your HTML, it's a little hard to discern exactly what you're doing and why you're looping the way you are.