i am writing to log files like this :
Function LogWrite
{
Param ([string]$str,[bool]$bPrintDate=$true);
if ($bPrintDate -eq $false) {
Add-content $global:LogPathName -Encoding Unicode -value $str;
}
else {
$now=Get-Date;
$str=[string]::concat($now,"`t",$str);
Add-content $global:LogPathName -Encoding Unicode -value $str;
}
}
and getting error :
Add-Content : The process cannot access the file 'D:\Logs\AD-AddUserManagers\20131113.log' because it is being used by another process.i don't see reason for this, i don't have multiple process that write to the same log file?