Help with ReportViewer ServerReport.SetDataSourceCredentials()

I’m basically trying to mimic some C# code and really struggling with it.

C#:
DataSourceCredentials cred = new DataSourceCredentials();
ReportDataSourceInfoCollection dataSource = rv.ServerReport.GetDataSources();
cred.Name = dataSource.First().Name;
cred.UserId = “admin”;
cred.Password = “pass”;
rv.ServerReport.SetDataSourceCredentials(new DataSourceCredentials[] { cred });

My attempt:
$DataSource = New-Object Microsoft.Reporting.WinForms.DataSourceCredentials
$DataSource.Name = $rv.ServerReport.GetDataSources().Name
$DataSource.UserID = “admin”
$DataSource.Password = “pass”
$rv.ServerReport.SetDataSourceCredentials($DataSource)

Any help? Thanks!

figured it out…

$DataSource = New-Object Microsoft.Reporting.WinForms.DataSourceCredentials
$DataSource.Name = $rv.ServerReport.GetDataSources().Name
$DataSource.UserID = “admin”
$DataSource.Password = “pass”
$rv.ServerReport.SetDataSourceCredentials([Microsoft.Reporting.WinForms.DataSourceCredentials[]]$DataSource)