Link to home
Get AccessLog in
Avatar of LeoKurz
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
Avatar of Neil Russell
Neil Russell
Flag of United Kingdom of Great Britain and Northern Ireland image

Where is the output file stored?
Avatar of rockiroads
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?
Avatar of LeoKurz
LeoKurz

ASKER

Hi,

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
Avatar of LeoKurz

ASKER

No, using Notepad, the userer who is *not* the owner of the file can not save it.

__Leo
Avatar of LeoKurz

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
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
Avatar of LeoKurz

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
ASKER CERTIFIED SOLUTION
Avatar of Neil Russell
Neil Russell
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This content is only available to members.
To access this content, you must be a member of Experts Exchange.
Get Access