I have a CSV file like below
Data,Name,Age
Test,T1,22
Test2,T2,23
Test3,T3,24
I want to do some processing like this
Foreach(header in CSvFile.Headers)
{
//Loop through the column data
}
EDIT : Displaying what I am looking for in real code.
Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue
$SiteUrl = "http://www.dev.com"
$Web = Get-SPWeb $SiteUrl
$description = "Group with contribute access."
$permissionLevel = "Contribute"
foreach($groupName in **CSV.Headers**)
{
$web.SiteGroups.Add($groupName, $web.SiteUsers["Test\data"], $web.SiteUsers["Test\data"], $description)
$group = $web.SiteGroups[$groupName]
$loc = Get-Location
$Users = "Test\data"
$roleAssignment = new-object Microsoft.SharePoint.SPRoleAssignment($group)
$roleDefinition = $web.Site.RootWeb.RoleDefinitions[$permissionLevel]
$roleAssignment.RoleDefinitionBindings.Add($roleDefinition)
$web.RoleAssignments.Add($roleAssignment)
$web.Update()
foreach ($User in **groupName.columnData**) {
$Web.EnsureUser($User)
Set-SPUser -Identity $User -Web $SiteUrl -Group $group
}
}
$Web.Dispose();
Can some one please tell me how to achieve this in powershell.
Thanks