» An ultimate catalog of computer data
Forum posts for savservice.exe
How to log output to file
powershell newb here. I am having some difficulty trying log my output to a file. I have tried two tactics, both of which do not work for me. The first is using the Start/Stop-Transcript cmdlet. This works great in testing on my local machine, but doesn't seem to work at all in a script that I deploy to workstations.
$path1 = Test-Path ($env:ProgramFiles + 'SophosSophos Anti-VirusSavService.exe')
$path2 = Test-Path (${env:ProgramFiles(x86)} + 'SophosSophos Anti-VirusSavService.exe')
$shareloc = '\SERVER1NETLOGONSophosPackagesSophosInstall_wFW_Silent.exe'
$logpath = '\SERVER1NETLOGONsi_sophos_log.txt'
if (($path1 -eq $true) -or ($path2 -eq $true)) {} ELSE {
& $shareloc
Start-Transcript -Append -Path $logpath | Out-Null
Write-Output ''
Get-Date
Write-Output 'Sophos has been installed on `'$env:COMPUTERNAME`''
Write-Output ''
Stop-Transcript
}
The way I would prefer to do it, is using: | Out-File -Append -FilePath $logpath
I think this would be the preferred method because it would catch any error that might occur in the log, as apposed to Start-Transcript. When I try to use this method however, I get an error at the pipeline 'An empty pipeline element is not allowed.'
$path1 = Test-Path ($env:ProgramFiles + 'SophosSophos Anti-VirusSavService.exe')
$path2 = Test-Path (${env:ProgramFiles(x86)} + 'SophosSophos Anti-VirusSavService.exe')
$shareloc = '\SERVER1NETLOGONSophosPackagesSophosInstall_wFW_Silent.exe'
$logpath = '\SERVER1NETLOGONsi_sophos_log.txt'
if (($path1 -eq $true) -or ($path2 -eq $true)) {} ELSE {
& $shareloc
Write-Output ''
Get-Date
Write-Output 'Sophos has been installed on `'$env:COMPUTERNAME`''
Write-Output ''
} | Out-File -Append -FilePath $logpath
Thank you in advance for any assistance!
View complete forum thread with replies
Other posts related to savservice.exe
See Related Forum Messages: Follow the Links Below to View Complete Thread
How to log output to file