Forum Discussion
Access denied when I want create to File in Powershell
- Feb 03, 2020
Hi darangua
I reread your post - I missed something in the original.
When you export out, you need to name the exported file name, not just the folder location. Try:
$cre | Export-Clixml -Path c:\test\name.xml
This will export out the name.xlm file in the test folder.
The result:
Hope this helps,
Mark
Hi darangua
I reread your post - I missed something in the original.
When you export out, you need to name the exported file name, not just the folder location. Try:
$cre | Export-Clixml -Path c:\test\name.xml
This will export out the name.xlm file in the test folder.
The result:
Hope this helps,
Mark
In my script, powershell is set to add a logfile after copying a file in the running script in
C:\LOGS
I was getting error
+ CategoryInfo : OpenError: (:) [Out-File], UnauthorizedAccessException
+ FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand
Resolved by
NTFS security permission to C:\Logs (the location of the folder where the file is out-put)
Permission was assigned to the Local Admin Service Account that was running the Task Schdule scipt
$LogFile = "C:\LOGS\LogFile_$(get-date -f yyyy-MM-dd).txt"