I have this powershell script as step 1 in a sql job.[System.Data.Sql.SqlDataSourceEnumerator]::Instance.GetDataSources()It creates a text extract with 4 columns as below.ServerName InstanceName IsClustered Version ---------- ------------ ----------- ------- ABCDEFGHI No 10.0.4000.0 ABCDEFGHI MSSQLSERVER2012 No 11.0.3000.0 SFVSDVSDV No 11.0.5058.0 HDDBHDGHH No 10.50.1600.1 I have this powershell script as step 2 in a sql job which is failing to an error stating sysntax issues.$SQL = [System.Data.Sql.SqlDataSourceEnumerator]::Instance.GetDataSources() | ' foreach {"INSERT INTO dbo.FoundSQLServers VALUES ('$($_.ServerName)', '$($_.InstanceName)', '$($_.IsClustered)', '$($_.Version)')" ' >> E:\ServersList.txt }[i]Error message:Date 11/21/2015 1:52:58 AMLog Job History (fgdfb)Step ID 2Server fffffffffJob Name ffffffStep Name ffffDuration 00:00:00MessageUnable to start execution of step 2 (reason: line(2): Syntax error). The step failed.[/i]The above script i supposed to extract data from E:\ServersList.txt and insert into this SQL tableCREATE TABLE [dbo].[FoundSQLServers]( [ServerName] [varchar](128) NULL, [InstanceName] [varchar](128) NULL, [IsClustered] [varchar](3) NULL, [VersionNumber] [varchar](64) NULL)Can someone please help figure this.Thanks
↧