locked
File Access Issues with Export-Csv RRS feed

  • Question

  • I'm executing the following PS script to retrieve a registry value from multiple remote servers and append the response to a CSV file hosted on the server running the script. Script content is as follows:

    Import-Csv E:\XXX\XXX\XXXXXXX\ServersList.csv -Header 'ComputerName' | ForEach {
        Invoke-Command -Computername $_.ComputerName `
        -ScriptBlock {
            Get-ItemProperty `
            -Path "HKLM:Software\Wow6432Node\XXXXX\XXXX\XXXXX\XXXXXX\TEST" `

            -Name "State" |
    Select-Object @{N="Server";E={$env:COMPUTERNAME}}, PSChildName, State |
    Export-Csv -Path "\\LocalServer\E\XXXXX\XXXXX\XXXXXX\LOG\RegistryValues.log" -Force -NoTypeInformation -Append
        }
    }

    The registry value is logged in the CSV correctly for the local server, but an execution against a remote server always results in an Access Denied:FileOpenFailure error message.

    All file and share permissions are verified as correct as far as I can tell.

    Any pointers greatly appreciated!

    Tuesday, January 22, 2019 5:46 PM

All replies