Good afternoon experts, I’m attempting to capture hundreds of entries from the following section of code ( modified from a powershell gallery script) into a file. The Start and Stop transcript is not working for each write-host entry it starts and stops the transcript command. Was toying with the idea of using the $output currently commented with a for each loop but that did not work, the output was not what I was looking for – the content of write-host into a file. Wondering if anyone could help me out with this
Thank you
Norm
#This function is used to Catalog the orphaned SID
$acl = Get-Acl -Path $Path
foreach($acc in $acl.access )
{
$value = $acc.IdentityReference.Value
if($value -match "S-1-5-*")
{
#Clear-Content -Path D:\PowerShell_temp\ListSIDFromACL_output.txt
#Start Logging
Start-Transcript -Path D:\Poweshell_temp\testlog0.txt
Write-Host "List SID: $value from $Path"
#Stop Logging
Stop-Transcript
#$Output = "List SID: $value from $Path"
}
}
}
catch
{
$errorlog = $Error | Out-String
Clear-Content -Path D:\PowerShell_temp\ListSIDFromACL_errors.txt
Add-Content -Path D:\PowerShell_temp\ListSIDFromACL_errors.txt -Value $ErrorLog
}