tolinrome
asked on
Powershell - Access to the path denied....
Ok, this is driving me crazy...I opened PS as "Run as administrator" and also as "different user" (which is domain admin), I have local admin rights to my computer and am part of domain admin and I still get access denied trying to save this file to the C drive.
I also ran "Set-ExecutionPolicy RemoteSigned".
Any help?
PS C:\Windows\system32> Get-Process | export-csv -path c:\
export-csv : Access to the path 'C:\' is denied.
At line:1 char:15
+ Get-Process | export-csv -path c:\
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (:) [Export-Csv], UnauthorizedAccessExceptio n
+ FullyQualifiedErrorId : FileOpenFailure,Microsoft. PowerShell .Commands. ExportCsvC ommand
I also ran "Set-ExecutionPolicy RemoteSigned".
Any help?
PS C:\Windows\system32> Get-Process | export-csv -path c:\
export-csv : Access to the path 'C:\' is denied.
At line:1 char:15
+ Get-Process | export-csv -path c:\
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (:) [Export-Csv], UnauthorizedAccessExceptio
+ FullyQualifiedErrorId : FileOpenFailure,Microsoft.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The error is thrown because you can't write a folder, only files. Its text sounds strange and misleading, but indeed it is "correct".
Get-Process | export-csv -path c:\filename.csv -force
Try set-executionpolicy unrestricted and see if the above works.
Try set-executionpolicy unrestricted and see if the above works.
Try his:
Enable "SeTakeOwnershipPrivilege" , using the example in this link http://channel9.msdn.com/Forums/Coffeehouse/Powershell-subinacl-ownership-of-directories
$acl = New-Object System.Security.AccessCont rol.Direct orySecurit y
$acl.SetOwner([System.Secu rity.Princ ipal.NTAcc ount]'BUIL TIN\Admini strators')
(Get-Item "C:\").SetAccessControl($a cl)
Enable "SeTakeOwnershipPrivilege"
$acl = New-Object System.Security.AccessCont
$acl.SetOwner([System.Secu
(Get-Item "C:\").SetAccessControl($a
marahman3001,
We already located the primary source of that error message and elaborated in depth about it. It is NOT an access privilege issue.
We already located the primary source of that error message and elaborated in depth about it. It is NOT an access privilege issue.
Open in new window