You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The logging is not working correctly in Windows Server 2012 R2 with PowerShell 4.
Every entry, that is internally created via the Log function is not logged in the file, only listed in the console.
Alternatively, you can replace Write-Host with Write-Out or Out-Host.
In SPSD_Utilities.ps1, the Write-Host is used 4 times.
It is not working to just replace Write-Host with Write-Output.
For Windows Server 2012 R2, you can just overwrite Write-Output with the following function, just inserted it below (Line 102)
# region Utilities.Logging
# region Log
This is the function to insert:
# replacement for Write-Host, which does not work for specific constellations of PS4 and Win Server 2012 R2
# see Hotfix https://support.microsoft.com/en-us/kb/3014136
Function Write-Host ($message,[switch] $nonewline,$backgroundcolor,$foregroundcolor) {
$Message | Out-Host
}
I don't think, this should be added to the standard SPSD functionality, therefore I did not change it as a Pull request. To create an issue seemed to be a good idea to me. Maybe s.o. finds an intelligent way to include this in the script, has a good place where to put this as a heads up or in the simplest case, maybe just adds this information as comment in the log function...?
The logging is not working correctly in Windows Server 2012 R2 with PowerShell 4.
Every entry, that is internally created via the Log function is not logged in the file, only listed in the console.
The cause is a bug in windows server 2012 R2.
This issue is also discussed in Technet: https://social.technet.microsoft.com/Forums/windowsserver/en-US/cecc4f32-28c8-4bdc-be63-49ce3d396625/powershell-4-starttranscript-does-not-log-writehost?forum=winserverpowershell
There exists a hotfix for windows server: see https://support.microsoft.com/en-us/kb/3014136
Alternatively, you can replace Write-Host with Write-Out or Out-Host.
In SPSD_Utilities.ps1, the Write-Host is used 4 times.
It is not working to just replace Write-Host with Write-Output.
For Windows Server 2012 R2, you can just overwrite Write-Output with the following function, just inserted it below (Line 102)
This is the function to insert:
I don't think, this should be added to the standard SPSD functionality, therefore I did not change it as a Pull request. To create an issue seemed to be a good idea to me. Maybe s.o. finds an intelligent way to include this in the script, has a good place where to put this as a heads up or in the simplest case, maybe just adds this information as comment in the log function...?
Cheers,
Achim
Some further information in German related to the logging issue can also be found here:
https://www.msxfaq.de/code/powershell/writehostdebugging.htm
The text was updated successfully, but these errors were encountered: