Import computers from csv Powershell

Hi,

I'm trying to import some computers within sccm via Powershell but get the following error:

PS STC:\> $Computers = Import-Csv "C:\computers.csv"
$CollectionName = "STC - W7 - Deploy"
ForEach ($Workstation in $Computers)
{
   Import-CMComputerInformation -ComputerName $Workstation.Name -MacAddress $Workstation.Mac -CollectionName $CollectionName
}

Import-CMComputerInformation : Cannot validate argument on parameter 'MacAddress'. System.Management.Automation.ValidationMetadataException
At line:5 char:77
+ ...  -ComputerName $Workstation.Name -MacAddress $Workstation.Mac -Collec ...

---

Csv contains:

Name,Mac
Computer1,0C:51:8F:7E:3D:04

Please advise.

April 24th, 2015 7:38am

Hello,

Try to enable column headings: Import-CMComputerInformation

Free Windows Admin Tool Kit Click here and download it now
April 24th, 2015 7:55am

Have a look at the EnableColumnHeadings parameter as described here: https://technet.microsoft.com/en-us/library/jj821991(v=sc.20).aspx
April 24th, 2015 8:01am

That does work but it only imports 1 computer (the last in my list).

Import-CMComputerInformation -CollectionName "All Systems" -FileName "c:\computers2.csv" -EnableColumnHeadings $True -verbose

csv

Name,Mac Address
test123,00:11:22:33:44:55
test3456,00:11:22:33:44:55
test75689,00:11:22:33:44:55
test899,00:11:22:33:44:55
test756689,00:11:22:33:44:55

Only test756689 is imported.

This is the verbose output:

VERBOSE: Start: Execution of WQL query: SELECT * FROM SMS_Collection WHERE CollectionType = 2 AND Name='All Systems' ORDER by Name
VERBOSE: Query options: None
VERBOSE: Performing the operation "Import" on target "ComputerInformation: c:\computers2.csv".
VERBOSE: Executing method 'ImportMachineEntry' against class 'SMS_Site'
VERBOSE: Input properties:
VERBOSE: -- :: NetBiosName == test123
VERBOSE: -- :: SMBIOSGUID ==
VERBOSE: -- :: MACAddress == 00:11:22:33:44:55
VERBOSE: -- :: OverwriteExistingRecord == True
VERBOSE: Output properties:
VERBOSE: -- :: MachineExists == True
VERBOSE: -- :: ResourceID == 16791724
VERBOSE: -- :: ReturnValue == 0
VERBOSE: -- :: SMSUniqueIdentifier == GUID:D86BB77F-4F29-4DFA-B8A1-874783E55FC0
VERBOSE: Executing method 'ImportMachineEntry' against class 'SMS_Site'
VERBOSE: Input properties:
VERBOSE: -- :: NetBiosName == test3456
VERBOSE: -- :: SMBIOSGUID ==
VERBOSE: -- :: MACAddress == 00:11:22:33:44:55
VERBOSE: -- :: OverwriteExistingRecord == True
VERBOSE: Output properties:
VERBOSE: -- :: MachineExists == True
VERBOSE: -- :: ResourceID == 16791724
VERBOSE: -- :: ReturnValue == 0
VERBOSE: -- :: SMSUniqueIdentifier == GUID:D86BB77F-4F29-4DFA-B8A1-874783E55FC0
VERBOSE: Executing method 'ImportMachineEntry' against class 'SMS_Site'
VERBOSE: Input properties:
VERBOSE: -- :: NetBiosName == test75689
VERBOSE: -- :: SMBIOSGUID ==
VERBOSE: -- :: MACAddress == 00:11:22:33:44:55
VERBOSE: -- :: OverwriteExistingRecord == True
VERBOSE: Output properties:
VERBOSE: -- :: MachineExists == True
VERBOSE: -- :: ResourceID == 16791724
VERBOSE: -- :: ReturnValue == 0
VERBOSE: -- :: SMSUniqueIdentifier == GUID:D86BB77F-4F29-4DFA-B8A1-874783E55FC0
VERBOSE: Executing method 'ImportMachineEntry' against class 'SMS_Site'
VERBOSE: Input properties:
VERBOSE: -- :: NetBiosName == test899
VERBOSE: -- :: SMBIOSGUID ==
VERBOSE: -- :: MACAddress == 00:11:22:33:44:55
VERBOSE: -- :: OverwriteExistingRecord == True
VERBOSE: Output properties:
VERBOSE: -- :: MachineExists == True
VERBOSE: -- :: ResourceID == 16791724
VERBOSE: -- :: ReturnValue == 0
VERBOSE: -- :: SMSUniqueIdentifier == GUID:D86BB77F-4F29-4DFA-B8A1-874783E55FC0
VERBOSE: Executing method 'ImportMachineEntry' against class 'SMS_Site'
VERBOSE: Input properties:
VERBOSE: -- :: NetBiosName == test756689
VERBOSE: -- :: SMBIOSGUID ==
VERBOSE: -- :: MACAddress == 00:11:22:33:44:55
VERBOSE: -- :: OverwriteExistingRecord == True
VERBOSE: Output properties:
VERBOSE: -- :: MachineExists == True
VERBOSE: -- :: ResourceID == 16791724
VERBOSE: -- :: ReturnValue == 0
VERBOSE: -- :: SMSUniqueIdentifier == GUID:D86BB77F-4F29-4DFA-B8A1-874783E55FC0

Free Windows Admin Tool Kit Click here and download it now
April 24th, 2015 8:54am

Hello,

You need to specify unique MAC addresses for each imported object.

April 24th, 2015 9:09am

How stupid of me. Did a copy paste as a test and didn't pay attention to that.
Logical indeed but symptom (only last one was entered) was leading me to the wrong conclusions.
Thanks!
Free Windows Admin Tool Kit Click here and download it now
April 25th, 2015 3:36pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics