Powershell workflow
when execute below csv file. doing wrong?
"pscomputername","psshowcomputername","pssourcejobinstanceid"
"localhost","true","9bead23a-9bcd-4d17-a801-a675766364af"
"localhost","true","9bead23a-9bcd-4d17-a801-a675766364af"workflow commvaultreport { $sqlserver = "dc07comserv01\commvault" #use server\instance named sql instances! $sqldbname = "commserv" $server_list=@("dc07nas01","dc21cvmsw1") foreach -parallel ($servername in $server_list) { inlinescript { ###second sql query### $sqlquery2 = "select a.[clientname], a.[idataagent], a.[subclient] from [dbo].[commcellbackupinfo] a" $sqlconnection2 = new-object system.data.sqlclient.sqlconnection $sqlconnection2.connectionstring = "server = $using:sqlserver; database = $using:sqldbname; integrated security = true" $sqlcmd2 = new-object system.data.sqlclient.sqlcommand $sqlcmd2.commandtext = $sqlquery2 $sqlcmd2.connection = $sqlconnection2 $sqladapter2 = new-object system.data.sqlclient.sqldataadapter $sqladapter2.selectcommand = $sqlcmd2 $dataset2 = new-object system.data.dataset $sqladapter2.fill($dataset2) $sqlconnection2.close() $subclientinfo2= $dataset2.tables[0]|where-object {$_.clientname -eq $using:servername} $b= $subclientinfo2 $subclientoutput= ($b.subclient|sort -unique) -join(";") $newobject01 = new-object psobject $newobject01 | add-member -membertype noteproperty -name "server name" -value $using:servername $newobject01 | add-member -membertype noteproperty -name "subclient names" -value $subclientoutput $newobject01 } } } commvaultreport | export-csv c:\script\backupreport.csv
???? code asked csv file.
i see no purpose suing workflow here.
\_(ツ)_/
Windows Server > Windows PowerShell
Comments
Post a Comment