Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Debug simple powershell script: get macaddress, username and netbios in csv file

$
0
0

Hi everybody,

I'm not a killer in powershell and i want to retrieve localhostname, current user logged in, and macaddresses of local computer to export all in CSV file.

I writed a litle script to do this and  I need your help to debug it  

Here is my script

$macAddresses = Get-WmiObject win32_networkadapterconfiguration
$tab=$macAddresses.macaddress
$netbiosName=$(Get-WmiObject Win32_Computersystem).name
$currentUser=$(Get-WmiObject Win32_Computersystem).username
foreach ($mc in $tab) {

write-output $mc
write-output $tab
write-output $netbiosName
write-output $currentUser

} | Export-Csv c:\temp\result.txt -NoTypeInformation -Encoding UTF8

here is error:

Thank you fro your help


Orwell


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>