PowerShell may be a better option. It allows you to test executing the data collection, quite easily, outside of the code. An example (NOT tested) might be...
#region SendDataToSMP
function SendDataToSMP {
[CmdletBinding(SupportsShouldProcess=$True,DefaultParameterSetName="None")]
PARAM(
[Parameter(Position = 0, Mandatory = $False, ValueFromPipeline = $True)]
$InputObject
,
[Parameter(Position = 1, Mandatory = $True, ValueFromPipeline = $True)]
[string]
$DataClass
,
[Parameter(Position = 2, Mandatory = $False, ValueFromPipeline = $True)]
[switch]
$Upload
,
[Parameter(Position = 3, Mandatory = $False, ValueFromPipeline = $True)]
[switch]
$Clear
,
[Parameter(Position = 4, Mandatory = $False, ValueFromPipeline = $True)]
[switch]
$ViewXML
,
[switch]
$NoNulls
)
# Create instance of Altiris NSE component
try {
$AeXNSEvent = New-Object -ComObject Altiris.AeXNSEvent
# Set the header data of the NSE
# This specifies the iteam as a Basic Inventory Capture Item (This should not be modified)
$AeXNSEvent.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}"
$AeXNSEvent.Priority = 1
# This is the Guid assigned to the Data Class within SMP.
# CAUTION: In earlier versions of SMP, this changes every time the Data Class definition is modified!
# The Guid must be enclosed in braces. Otherwise, it considers it the name and does not work.
if ($DataClass -is [Guid]) {$DataClass = ([Guid]$DataClass).ToString('B')}
# Create section based on Data Class guid
$DataClassInstance = $AeXNSEvent.AddDataClass($DataClass)
$DataBlockInstance = $AeXNSEvent.AddDataBlock($DataClassInstance)
if ($InputObject -and (!$Clear)) {
foreach ($Object in $InputObject) {
$RowInstance = $DataBlockInstance.AddRow()
$Object | foreach {
$Iteration = 0
foreach ($Property in $_.PSObject.Properties) {
$Value = $Property.Value
if (($NoNulls) -and $Value -eq $null) {$Value = ''}
if ($Value -ne $null) {$RowInstance.SetField($Iteration, "$($Value)")}
$Iteration++
}
}
}
}
# Show
if ($ViewXML) {$AeXNSEvent.xml}
# Queue NSE for upload
if ($Upload) {$AeXNSEvent.SendQueued()}
} catch {
}
}
#endregion
$Data = Get-ItemProperty -Path "Registry::HKEY_CURRENT_USER\Network\*" | Select @{Name="DriveLetter";Expression={"$($_.PSChildName):"}},RemotePath
SendDataToSMP -InputObject $Data -DataClass "E30CF469-1720-4452-B3BC-7248D42A861A" -ViewXML
A couple of things to know about the SendDataToSMP function. The Select statement on the InputObject provides the order for the rows of the DataClass in the SMP database.
The above code should allow for testing to see what the output looks like. Change -ViewXML to -Upload to send data to the database.
Cheers