Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Using Data from a Dataset

$
0
0

Hi,

I am new to Powershell and need help on how to pass data into a function from a dataset.

I was thinking I could use "foreach ($row in $ds.Tables[0].Rows)" within the function but its not working.

I want each row from the dataset (computer name) to replace this section $MachineNames.split(',')

Function Main
{
$sccmProviderLocation = Get-WmiObject -query "select * from SMS_ProviderLocation where ProviderForLocalSite = true" -Namespace "root\sms" -computername $SccmServer
$SiteCode = $sccmProviderLocation.SiteCode
$SccmNamespace = "root\sms\site_$SiteCode"
Add-SCCMDirectMachineRules -SccmServer $SccmServer -SccmNamespace $SccmNamespace -CollectionID $CollectionID -MachineNames $MachineNames.split(',')
}


Viewing all articles
Browse latest Browse all 6937

Trending Articles