Additional Script for OSD Webportal: Part5 OSDWP

What about a Mass import of Client Objects, the need for this is that you have a migration project and would like to import all client objects in CM12 with to a Location and also to a OS-Deployment Collection to do all the stuff that are described in the Part4 OSDWP.

First you need a CSV File that includs the Data of all Client informations:

pc01;11:22:33:44:55:ab;Japan;Windows8
pc02;11:22:33:44:55:ac;Japan;Windows8
pc03;11:22:33:44:55:ad;Japan;Windows8
pc04;11:22:33:44:55:ae;Japan;Windows8
pc05;11:22:33:44:55:af;Japan;Windows8
pc06;11:22:33:44:aa:ab;lala;Windows8
pc07;11:22:33:44:5b:ab;Japan;Windows8
pc08;11:22:33:44:5c:ab;Jaja;Windows8
pc09;11:22:33:44:5d:ab;Japan;Windows8
pc10;11:22:33:44:5e:ab;USA;Windows8
pc11;11:22:33:44:5f:ab;Japan;Windows8
pc12;11:22:33:44:af:ab;IT Dev;Windows8

Computername;MACAdress;Location;OperatingSystem

Save the File as ImportObjects.csv to C:\temp

After that you can download the following Powershell Script:

Param($pfad = "c:\")
<#
.SYNOPSIS
    This Script imports the Objects from a CSV File and create the Objects in Configuration Manager
.Parameter pfad
    Set the Path to the CSV File
.DESCRIPTION 
    Change the Path http://localhost/OSDWebService to the CM-Server OSDWebService,
    otherwise run the Script on your CM-Server
.NOTES  
    File Name  : OSDWP-CSV-Import.ps1  
    Author     : Mirko Colemberg - mirko@colemberg.ch  
    Requires   : PowerShell V3 
.LINK 
    http://gallery.technet.microsoft.com/scriptcenter/OSD-Webportal-10139926-e13f2d78
#>
    

if(test-path $pfad)
{
$CM = New-WebServiceProxy -Uri:"http://localhost/OSDWebService" -UseDefaultCredential

Import-Csv $pfad -delimiter ";" -header name, macadress, location, os | %{
    $CM.CreateDevice($_.name,$_.macadress)
    $CM.AssignLocation($_.name,$_.location)
    $CM.AssignOS($_.name,$_.os)}
}

Thank you Joris Baiutti to help me with this script….

Copy the code and Crate a file with the Name OSDWP-CSV-Import.ps1
If you would like to run the Script with commandline use this  .\OSDWP-CSV-Import.ps1 -pfad c:\temp\ImportObjects.csv
All information is provided “as is” without any warranty! Try in lab before. Handle with care in production!

Comments

Leave a Reply

Follow

Get every new post delivered to your Inbox

Join other followers:

%d bloggers like this: