answerhasem.blogg.se

Shell in mac text file
Shell in mac text file











shell in mac text file

For each computer name read from the text file the ' : of computer names to enumerate the IP and MAC addresses. 'Description : This script reads a text file from the scripts working directory named "ComputerNames.txt" containing a list Hey It's not too complicated, here is a script that will generate a comma seperated log file in the following format: Computer Name,IP Address,MAC Address,Network Status TESTVM01,192.168.1.10,00:03:FF:E2:B6:38,Online This should work assuming that you have access on all remote hosts to enumerate the ip configuration via WMI. Next And here is a for command you can use: for /f %c in (List.txt) do //Nologo GetMAC.vbs %c > Output.txt In this example, the file 'List.txt' contains a list of computer names, and '>' saves the output to the file 'Output.txt', which you can import into a spreadsheet or database. WScript.Echo """" & ComputerName & """,""" & Adapter.MACAddress & """" Set Adapters = WMI.ExecQuery("select MACAddress from " _ Here is GetMAC.vbs (it outputs CSV data): Dim Args, ComputerName, WMI, Adapters, Adapter The WSH script only needs to accept a single command line argument as the computer name for which you want to retrieve the MAC address(es). Hi AC2006, I recommend a simpler approach - I've found it's easier to use the 'for' command (or get-content in PowerShell) to loop through computer names with a WSH script. WScript.Echo """" & ComputerName & """," _ & "Win32_NetworkAdapterConfiguration where IPEnabled=true") Set Configs = WMI.ExecQuery("select IPAddress,MACAddress from " _ WScript.Echo "Error " & Hex(Err.Number) & " connecting to " & ComputerName Set WMI = GetObject("winmgmts://" & ComputerName & "/root/cimv2") WScript.Echo "Please specify a computer name on the command line" Here is an updated script, GetIPAndMac.vbs, that retrieves the IP addresses and adds them to the CSV output: Dim Args, ComputerName, WMI, Configs, Config It adds a bit to the script, but it's not overly complicated. I briefly looked into adding the PC's IP address to the output, but it seems that makes it complicated since it's stored in an array. MsgBox "MultiMAC is finished", 0, "MultiMAC" = Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery _ ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")įor Each objItem in colItems objTextFile.WriteLine(objItem.MACAddress) Next objTextFile.Close End Sub While Not tst.AtEndOfStream strMachineName = tst.readLine echoMAC strMachineName Wend = Dim fso Dim tst Dim strMachineName Dim objFSO Dim objTextFileĬonst ForAppending = 8 Set fso = createObject("Scripting.FileSystemObject") Set tst = fso.OpenTextFile("C:\Temp\MAC\Computers.txt", 1, false) Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextFile = objFSO.OpenTextFile("C:\Temp\MAC\MacAddresses.txt", ForAppending, True)

Shell in mac text file how to#

I also, haven't figured out how to get it to write the corresponding PC name (just writing the MAC address isn't too helpful with out the PC name). It only writes the MAC address of the first PC in the list, so I'm guessing it isn't looping correctly.

shell in mac text file

I tried to modify it to write to a text file instead, but it's not working correctly. I found a script that displays the MAC address in a text box on screen. I need to create a vb script that reads a list of computer names from a text file and then writes the computer name and it's MAC address to another text file.













Shell in mac text file