I have a SQL Server, SQL Database, and Company array that I need to run a forEach Loop on.
I can do it with a single value array but I have NO idea how to do it for multiple arrays needing the information from the other arrays
Each position in the array corresponds to information about the others. i.e. Company1 uses DB01 with database AR_Agency1, Company2 uses DB02 and database AR_Agency2(See array below).
Ex:
$Company = (“Company1″,”Company2″,”Company3″,”Company4″,”Company5”)
$DatabaseServer = (“DB01”, “DB02”, “DB03”, “DB04”, “DB02”)
$Database= (“AR_Agency1”, “AR_Agency2”, “Agency3”, “Agency4”, “Agency5”)
#SQL Query
$Query = ‘UPDATE tblAsyncJobQueue SET InactiveUntil = NULL’
#Invoke-Sqlcmd -ServerInstance $DatabasesServer -Database $Database -Query $Query
#So what I want to do is
ForEach ($company in $companies) {
#RunTheQuery
}
End state I need the query run on each Company database.
Thanks