LeoKurz
asked on
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
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
Where is the output file stored?
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?
ASKER
Hi,
I created a directory c:\bu-script
__Leo
I created a directory c:\bu-script
__Leo
can BOTH users edit the text file that is created by using notepad.exe ?
A simple test
A simple test
ASKER
No, using Notepad, the userer who is *not* the owner of the file can not save it.
__Leo
__Leo
ASKER
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
__Leo
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
Or jus double check that both have READ/WRITE to the file & folder
ASKER
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
__Leo
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.