If I run this command I can get the mac address off a pc with no problems.
Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName computer| Select-Object -Property macaddress
Now if I put a bunch of workstations into a text file and do a get-content it shows how many objects are in there (51). Yet all three of these scripts are failing for me and I cant figure out why. Replacing the computer name above with the variable and it fails. The error is useless to me, say the RPC server is unavailable. Does anyone see a problem?
foreach ($i in get-content "c:\temp\computers.txt")
{Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName $i} | Select-Object -Property macaddress
get-content c:\temp\computers.txt | foreach-object {Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName $_} | Select-Object -Property macaddress
$s = get-content c:\temp\computers.txt
foreach ($i in $s) {Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName $i} | Select-Object -Property macaddress
Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName computer| Select-Object -Property macaddress
Now if I put a bunch of workstations into a text file and do a get-content it shows how many objects are in there (51). Yet all three of these scripts are failing for me and I cant figure out why. Replacing the computer name above with the variable and it fails. The error is useless to me, say the RPC server is unavailable. Does anyone see a problem?
foreach ($i in get-content "c:\temp\computers.txt")
{Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName $i} | Select-Object -Property macaddress
get-content c:\temp\computers.txt | foreach-object {Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName $_} | Select-Object -Property macaddress
$s = get-content c:\temp\computers.txt
foreach ($i in $s) {Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName $i} | Select-Object -Property macaddress