Solved

Powershell write to text file owned by s/o else

Posted on 2010-09-13
11
544 Views
Last Modified: 2012-08-14
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
0
Comment
Question by:LeoKurz
  • 4
  • 4
  • 2
11 Comments
 
LVL 37

Expert Comment

by:Neil Russell
ID: 33662499
Where is the output file stored?
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 33662503
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
 

Author Comment

by:LeoKurz
ID: 33662570
Hi,

I created a directory c:\bu-script

__Leo
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 37

Expert Comment

by:Neil Russell
ID: 33662615
can BOTH users edit the text file that is created by using notepad.exe ?
A simple test
0
 

Author Comment

by:LeoKurz
ID: 33662654
No, using Notepad, the userer who is *not* the owner of the file can not save it.

__Leo
0
 

Author Comment

by:LeoKurz
ID: 33662768
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
 
LVL 37

Expert Comment

by:Neil Russell
ID: 33662787
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
 
LVL 65

Expert Comment

by:rockiroads
ID: 33663008
0
 

Author Comment

by:LeoKurz
ID: 33663176
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
 
LVL 37

Accepted Solution

by:
Neil Russell earned 500 total points
ID: 33663388
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

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Utilizing an array to gracefully append to a list of EmailAddresses
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question