none
Powershell get computer name, user , mac adress of wire and wireless card to a csv RRS feed

  • Question

  • Hello

    I want to create a script that will log on the server the computer name, username , and wire and wireless macaddress  to a csv it will append to a csv one computer per line and this is run on the computer by the tech

    this is what I have so far I cant get to do per row and cant get the username for some reason

    Get-WmiObject win32_networkadapter -Filter "(adaptertype like '%ethernet%' AND servicename <> 'BthPan')" -ComputerName $env:COMPUTERNAME | Where { $_.PhysicalAdapter -eq 'TRUE' } | select Tech, PSComputername, Description, Macaddress | Sort-Object $env:username, PSComputername, Description -Descending | Export-Csv \\server\result.csv -Append -Force
    
    
    Thanks in advance

    Saturday, August 26, 2017 11:35 PM

Answers

  • This is how to do this:

    $wmifilter = 'PhysicalAdapter=True AND AdapterType LIKE "%ethernet%" AND servicename <> "BthPan"'
    Get-WmiObject win32_networkadapter -Filter $wmifilter | 
    	Select-Object @{n='Tech';e={$env:USERNAME}}, PSComputername, Description, Macaddress | 
    	Export-Csv \\server\result.csv -Append
    


    \_(ツ)_/

    • Marked as answer by NateCal Sunday, August 27, 2017 3:03 PM
    Sunday, August 27, 2017 12:04 AM

All replies

  • This is how to do this:

    $wmifilter = 'PhysicalAdapter=True AND AdapterType LIKE "%ethernet%" AND servicename <> "BthPan"'
    Get-WmiObject win32_networkadapter -Filter $wmifilter | 
    	Select-Object @{n='Tech';e={$env:USERNAME}}, PSComputername, Description, Macaddress | 
    	Export-Csv \\server\result.csv -Append
    


    \_(ツ)_/

    • Marked as answer by NateCal Sunday, August 27, 2017 3:03 PM
    Sunday, August 27, 2017 12:04 AM
  • Thanks
    Sunday, August 27, 2017 3:03 PM