The story - running a command like this in a script with the 2 other domain computers and the workstation where the script is run from, sends output to the file from only the other 2 computers so I am trying to narrow the problem down to what won't work.
This works from the prompt, sending the output to the file on a remote share:
PS C:\blah> invoke-command -computer win10 -script {Get-EventLog -LogName "security" -Newest 5} | Out-
File \\server2\giggedy\mytest.txt
This doesn't work from the prompt:
PS C:\blah> Invoke-Command -Computer win10 -Script {Get-EventLog -LogName "security" -Newest 5 | Out-F
ile \\server2\giggedy\mytest.txt -Append; Get-EventLog -LogName "System" -Newest 5 | Out-File \\server2\giggedy\mytest.t
xt -Append}
Access to the path is denied.
Running the actual script like this:
$compname = "server1","server2","win10"
Invoke-Command -ComputerName $compname -Scriptblock {
Get-EventLog -LogName "security" -Newest 5 | ConvertTo-Html | Out-File \\server2\giggedy\mytest.html -Append;
Get-EventLog -LogName "System" -Newest 5 | ConvertTo-Html | Out-File \\server2\giggedy\mytest.html -Append
}
sends the output to the file only from the servers and returns same "Access to path is denied" as above for the win10 computer.
The actual error:
Access to the path '\\server2\giggedy\mytest.html' is denied.
+ CategoryInfo : OpenError: (:) [Out-File], UnauthorizedAccessException
+ FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand
+ PSComputerName : win10
Any insights?
Randy