searched a lot but couldn't find a solution to my problem. First I have a script from which i make a few querys through a local Veeam database. It has a few select querys but everytime I run it, it just gives me the results of the first one but not from the others. I just tried to make the code a little more skinny so maybe somebody could give me a tip I just get the results for $job and $space_backup. I don't want to have four different querys but if it's not possible I have to go with it. I would appreciate any help.
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server=$dbServer;Database=$db;uid=$User;password=$Pass;"
$SQLConnection.Open()
$SQLCommand = $SQLConnection.CreateCommand()
$SQLCommand.CommandText =
"SELECT TOP 1 stored_size AS size, job_name AS job FROM [VeeamBackup].[dbo].[ReportSessionView] ORDER BY [creation_time] DESC;"
"SELECT [free_space] AS [free] FROM [VeeamBackup].[dbo].[BackupRepositories] WHERE (name != 'Default Backup Repository');"
"SELECT SUM(backup_size) AS backupsize FROM [VeeamBackup].[dbo].[WmiServer.RestorePointsView];"
"SELECT TOP 1 reason AS Reason, stop_details AS Detail FROM [VeeamBackup].[dbo].[Backup.Model.JobSessions] ORDER BY creation_time DESC;"
$SQLReader = $SQLCommand.ExecuteReader()
foreach($SQLCommand in $SQLReader.Read()){
$space_backup = $SQLReader["size"]
$job = $SQLReader["job"]
$space_free = $SQLReader["free"]
$space_all = $SQLReader["backupsize"]
$reason = $SQLReader["Reason"]
$detail = $SQLReader["Detail"]
$SQLReader.Close()
}