SOLVED

Access denied when I want create to File in Powershell

Copper Contributor

Hi,

Please, your help me!

I have problem to access denied, when i want create to file.

I have the account in the group administrator.

I valued the permission in the tab security and i have administrator permission.

 

PS U:\> $cre | Export-Clixml -Path C:\
Export-Clixml : Acceso denegado a la ruta de acceso 'C:\'.
En línea: 1 Carácter: 8
+ $cre | Export-Clixml -Path C:\
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (:) [Export-Clixml], UnauthorizedAccessException
+ FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.ExportClixmlCommand

clipboard_image_0.png

Regards.

#PowerShell

 

6 Replies

Hi @darangua 

 

If I remember correctly the C:\ drive is normally locked down extra tight to stop files appearing in the root. Are you able to use another location (i.e. C:\outputfolder)? If not, can you let me know what OS you are using (i.e. Windows 10 home, Server 2019 etc) and if this is a domain joined computer?

 

Thanks,

Mark

Hi @HidMov ,

 

I trying with another path and the same error.

The error is S.O Windows 10 pro and Windows server 2019 Standard, the computers in domain

Error:

PS U:\> $cre | Export-Clixml -Path C:\Test
Export-Clixml : Acceso denegado a la ruta de acceso 'C:\Test'.
En línea: 1 Carácter: 8
+ $cre | Export-Clixml -Path C:\Test
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (:) [Export-Clixml], UnauthorizedAccessException
+ FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.ExportClixmlCommand

 

Regards.

 

 

 

best response confirmed by darangua (Copper Contributor)
Solution

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.

 

clipboard_image_0.png

 

The result:

 

clipboard_image_1.png

 

Hope this helps,

 

Mark

the message to error "denied" is not very clear jajaja , very thanks

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"

1 best response

Accepted Solutions
best response confirmed by darangua (Copper Contributor)
Solution

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.

 

clipboard_image_0.png

 

The result:

 

clipboard_image_1.png

 

Hope this helps,

 

Mark

View solution in original post