/build/static/layout/Breadcrumb_cap_w.png

Scripting Question


Powershell script to append a text file on local user profiles

06/03/2015 928 views
Hi Guys ,

I hope you are well. I am working on a script that appends a text file on local user profiles but  excludes Admin profiles named "Admin-xxx" and public folder. So far this is what I have but getting no luck. 
-------------------------------------------------------------------------------------------------
1
2
ForEach ($user in (Get-ChildItem "C:\Users" -Exclude Public,Admin%)) { Add-Content C:\$user\AppData\Roaming\App\app.txt "Text" }
----------------------------------------------------------------------

Any advice will be highly appreciated. Have a nice day.


0 Comments   [ + ] Show comments

Comments


All Answers

0
Isn't line 2 incorrect, as the path should be C:\users\$user\Appdata\Roaming\...etc
Answered 06/08/2015 by: EdT
Red Belt

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ