[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 558
  • Last Modified:

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
0
LeoKurz
Asked:
LeoKurz
  • 4
  • 4
  • 2
1 Solution
 
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
 
LeoKurzAuthor Commented:
Hi,

I created a directory c:\bu-script

__Leo
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
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
 
Neil RussellTechnical 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

Featured Post

Will You Be GDPR Compliant by 5/28/2018?

GDPR? That's a regulation for the European Union. But, if you collect data from customers or employees within the EU, then you need to know about GDPR and make sure your organization is compliant by May 2018. Check out our preparation checklist to make sure you're on track today!

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now