Powershell write to text file owned by s/o else

Hello,

I'm writing a powershell script that writes log infos to a text file using the "Add-Content" command. All works fine as long as I use the same windows user. As soon as another user starts the script, the log file can't be appended any more (access denied). Both users are in the local Administrators group and looking into the effective rights, the second user has full permissions.

Any idea?

__Leo
LeoKurzAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Neil RussellConnect With a Mentor Technical Development LeadCommented:
Then you will have to elevate or switch off UAC I think to get the desired rights. UAC is a pain in the A**!
0
 
Neil RussellTechnical Development LeadCommented:
Where is the output file stored?
0
 
rockiroadsCommented:
where is this file? is it in the users personal directories? maybe something like uac might be stopping it. have u tried aa a test write to \temp?
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

 
LeoKurzAuthor Commented:
Hi,

I created a directory c:\bu-script

__Leo
0
 
Neil RussellTechnical Development LeadCommented:
can BOTH users edit the text file that is created by using notepad.exe ?
A simple test
0
 
LeoKurzAuthor Commented:
No, using Notepad, the userer who is *not* the owner of the file can not save it.

__Leo
0
 
LeoKurzAuthor Commented:
Did another test, opened notepad with a right-click -> Open as Administrator, opened the file, modified it and was able to save the modified file. So I think it has to do with uac. This is weered! I have all permissions and still can't write! Anyone any idea how to get this solved w/o having to run the sript with elevated privileges? I *do* have all fs permissions.

__Leo
0
 
Neil RussellTechnical Development LeadCommented:
Then your issue is purely one of ownership. As the user who can NOT save the file, can you open the file security tab and post here a screen shot?
Or jus double check that both have READ/WRITE to the file & folder
0
 
LeoKurzAuthor Commented:
Filesystem rights are all there. It seems that with uac, a user can not write into another file owned by another user, even though all the file permissions are in place. This is crab! I changed the ownership to the local administrator group, no help.

__Leo
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.