Working in PowerShell I need to export the App Pool information into a CSV and then export it to a different server on the network. When I run the following command:
Get-Website |
select name, id, state, physicalpath,
@{n="Bindings";e={($_.bindings | select -expa collection) -join ';'}} |
Export-Csv -NoTypeInformation -Path \\prod-web5\e$\Hosted-1.csv
I receive the following Error:
Export-Csv : Access to the path '\\prod-web5\e$\Hosted-1.csv' is denied. At line:3 char:11 + Export-Csv <<<< -NoTypeInformation -Path \\prod-web5\e$\Hosted-1.csv + CategoryInfo : OpenError: (:) [Export-Csv], UnauthorizedAccessException + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.ExportCsvCommand
I can access the path through file explorer I have permissions to modify the files and write to the directory but I receive this error. From the research I have done the common solutions did not resolve the issue, Making sure the file name has extensions and etc.
I can use the C:\whatever and it will write to the C drive but I can not write to the other server.
I have also check with the Antivirus program because I noticed sometimes it will interfere with PowerShell. However, in this instance it is not affecting it.