HEMIChallenger
asked on
csv file
import-csv Computers.csv |
foreach {
$system = "" |
select PCName, UserName, MacAddress, IPAddress
$colItems = Get-WmiObject -Class Win32_NetworkAdapterConfiguration `
-ComputerName $_.Computer -Filter "IpEnabled = TRUE AND NOT Caption LIKE '%VMware%' AND NOT Caption LIKE '%VirtualBox%'"
ForEach ($objItem in $colItems){
$System.MacAddress = $objItem.MacAddress
$System.IPAddress = $objItem.IpAddress[0]}
$server = Get-WmiObject -Class Win32_ComputerSystem `
-ComputerName $_.Computer
$System.PCName = $server.Name
$System.UserName = $server.UserName
$system
} |
Export-Csv c:\Computer-info.csv -NoType
Could someone help me out with this. I'm new to powershell and the script I created kind of works. The issue is if the computer cant be contacted I get errors in powershell. The computer that are online the information is gathered. but is it possible if the computers that are not reachable that it write in the export CSV file that computer blank could not be contacted.
Great solution provided.
@dbaduck Thanks.. :-)
ASKER
That works great, thank you Sir. Curious if there no current user logged on. Is it possible to get the last person who logged on to the computer? By using a \\computer\c$\users\ and get the last modified name? Unless there another way.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you sir. okay I will keep that in mind next time sorry about that.
No problem!..
Open in new window