I have the following script:
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") $sqlServerNames = "computername" [Array]$Collection = foreach ($sqlServerName in $sqlServerNames) { $sqlServer = New-Object Microsoft.SqlServer.Management.Smo.Server($sqlServerName) foreach ($job in $sqlServer.JobServer.Jobs) { $job | Select-Object Name, OriginatingServer, OwnerLoginName, IsEnabled, LastRunDate, LastRunOutcome, DateCReated, DateLastModified, NextRunDate } $Collection += $job } $Collection | Export-CSV "\\computername\c$\\sqljobs.csv" -force –noType -Encoding:UTF8
When i run this in powershell, I’ve no problems. However when i run via task scheduler with admin rights with the following parameters: -NoLogo -NonInteractive -File “\computername\c$\Powershell\SF3.ps1”
The csv file just comes up blank.
Any ideas? Thank you.