Solved

Powershell write to text file owned by s/o else

Posted on 2010-09-13
11
542 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
 
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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

895 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now