Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *ToolId* *ProductId*
- T001 ProductA
- T001 ProductB
- T002 ProductA
- T002 ProductC
- *ToolId* *ProductId*
- T001 ProductA; ProductB
- T002 ProductA; ProductC
- Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
- #Get the context
- $ctx = Get-SPServiceContext https://path
- #Get the scope
- $scope = new-object Microsoft.SharePoint.SPServiceContextScope $ctx
- #Get the target site collection
- $webTarget = Get-SPWeb -identity "https://path"
- #Get the Target List
- $list = $webTarget.Lists["Name of List"]
- #Array to Hold Result - PSObjects
- $ListItemCollection = @()
- #Get All List items
- $list.Items | Where-Object { $_["ToolId"] -ne ''} | foreach {
- $ExportItem = New-Object PSObject
- $ExportItem | Add-Member -MemberType NoteProperty -name "ToolId" -value $_["ToolId"]
- $ExportItem | Add-Member -MemberType NoteProperty -name "ProductId" -value $_["ProductId"]
- #Add the object with property to an Array
- $ListItemCollection += $ExportItem
- }
- #Export the result Array to CSV file
- $ListItemCollection | Export-CSV "\pathtest.csv" -NoTypeInformation
- #Dispose the web Object
- $webTarget.Dispose()
- $ListItemCollection | Group-Object ToolId |
- Select @{ Label = "ToolId"; Expression = { $_.Name } }, @{ Label = "Products"; Expression = { ($_.Group | Select-Object -ExpandProperty ProductId) } }
- $ListItemCollection | group ToolId | select @{ L = "ToolId"; E = { $_.Name } }, @{ L = "Products"; E = { $_.Group.ProductId } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement