Did you already try passing the array row by row and declaring the parameters?
[CmdletBinding()]
param(
[string]$vCenter,
[string]$Cluster,
[string]$VMName,
[string]$IPAddr,
[string]$PowerState
)
$output_Server = "MySQLserver.domain.com"
$output_Database = "My_Database"
$output_Username = "myUsername"
$output_Password = "myPassword!"
$Date = Get-Date
$output_vCenter = $VMinfo.vCenter
$output_Cluster = $VMinfo.Cluster
$output_VMname = $VMinfo.'VM Name'
$output_IP = $VMinfo.'IP Address'
$output_PowerState = $VMinfo.PowerState
$SQL_Property = "USE $output_Database
INSERT INTO [My_Database].[dbo].[VM_Info] (Date, vCenter, Cluster, VM_Name, IP_Address, PowerState)
VALUES('$Date', '$vCenter', '$Cluster', '$VMName', '$IPAddr', '$PowerState');"
#echo $SQL_Property
$SQL_Property_Insert = Invoke-Sqlcmd -Query $SQL_Property -ServerInstance $output_Server -Username $output_Username -Password $output_Password
}
$VMinfo | ForEach-Object -process {
Out_SQL $_.vCenter $_.Cluster $_.'VM Name' $_.'IP Address' $_.PowerState
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference