Serial number RRS feed

  • General discussion

  • *Deleted*

    • Edited by MeirPeleg Thursday, May 25, 2017 7:36 AM
    • Changed type jrv Thursday, May 25, 2017 7:39 AM abandoned
    • Moved by jrv Thursday, May 25, 2017 7:40 AM abandoned
    Thursday, May 25, 2017 5:41 AM

All replies

  • If you were to format the code correctly I think you would see all of the problems.

    Why are you putting parens around everything?  How can you get the serial number from a "Test-Connection

    Start by using help to read about how each command works. 

    Is this your first homework problem?  It looks like a class day one challenge.  Figure out how to get something from a list of computers.

    When learning how to write code build one piece at a time and test it until you understand how it works.


    Thursday, May 25, 2017 6:01 AM
  • ****

    • Edited by MeirPeleg Saturday, October 7, 2017 7:46 PM
    Thursday, May 25, 2017 6:07 AM
  • Are you asking for someone to re-write your script for you?  This is a technical forum for technicians who use scripting or who are learning scripting.  It is not a free script fixing or writing forum.

    Here is how to format a script

    $ComputerList = get-content -path C:\Computerlisr\Comp.txt
    $WmiQuery = $WmiQuery = (Get-WMIObject Win32_BIOS).serialnumber
    Foreach ($Computer In $ComputerList) {
    	if($Ping = Test-Connection -count 1 $Computer -ErrorAction SilentlyContinue) { 
    		write-host Compuer $Computer  SN is: $WmiQuery -ForegroundColor "Green" 
    	if (-not $Ping) { 
    		Write-host The computer $Computer  Is not available, Probably no Ping -ForegroundColor "white" 

    start with:

    help about_if
    help about Get-WmuObject -full
    help about_foreach

    You cannot get one serial number and apply it to all computers.

    You have also not told us what is not happening or what errors you are getting.  We cannot guess.


    • Edited by jrv Thursday, May 25, 2017 6:15 AM
    Thursday, May 25, 2017 6:14 AM
  • OK

    • Edited by MeirPeleg Thursday, May 25, 2017 7:35 AM
    Thursday, May 25, 2017 7:34 AM