[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

specify a PS script in group policy.

Posted on 2016-08-30
4
Medium Priority
?
44 Views
Last Modified: 2016-09-10
I am working on a powershell script to copy an ini file from a network share to a directory in the user profile when he logins.  

The destination path is something like \\server2\profiledir\%username%\appdata\roaming\vlc\vlc-qt-interface.ini

can I specify this PS1 file in USER CONFIGURATION /POLICIES/WINDOWS SETTINGS/SCRIPT/LOGON of my GP?

Thanks.
0
Comment
Question by:nav2567
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 83

Expert Comment

by:David Johnson, CD, MVP
ID: 41777051
it will have to be in the user settings not the computer settings
I'd use
%userprofile%\appdata\roaming\vlc\vlc\vlc-qt-interface.ini 

Open in new window

for the destination rather than
 \\server2\profiledir\%username%\appdata\roaming\vlc\vlc-qt-interface.ini

Open in new window


you will have to in the computer settings create and run a batch file that runs the following
powershellpolicy.cmd
C:\windows\system32\windowspowershell\v1.0\powershell.exe -executionpolicy bypass -file .\copyfile.ps1

Open in new window


copyfile.ps1
$source = \\server\share\vlc-qt-interface.ini
$destination = $env:userprofile + '\appdata\roaming\vlc\vlc\vlc-qt-interface.ini'
if (!(test-path $source))
     { 
     "Source Path $source not available" | out-file \\server\share\logs\copyfilefailures.txt -append
     }
else {
    try{
        copy-item -source $source -destination $destination
        }
    catch
        {
        'Destination error:' + $destination | out-file  \\server\share\logs\copyfilefailures.txt -append 
        }
}

Open in new window

0
 
LVL 43

Expert Comment

by:Adam Brown
ID: 41777090
I would use a File preference to place the file to %AppDataDir%\roaming\vlc\vlc-qt-interface.ini

Preferences work significantly better than login scripts and are much more reliable. https://technet.microsoft.com/en-us/library/cc772536(v=ws.11).aspx has info.
0
 
LVL 83

Accepted Solution

by:
David Johnson, CD, MVP earned 2000 total points
ID: 41777148
fixed missing quotes in $source directory
$source = '\\server\share\vlc-qt-interface.ini'
$destination = $env:userprofile + '\appdata\roaming\vlc\vlc\vlc-qt-interface.ini'
if (!(test-path $source))
     { 
     "Source Path $source not available" | out-file \\server\share\logs\copyfilefailures.txt -append
     }
else {
    try{
        copy-item -source $source -destination $destination
        }
    catch
        {
        'Destination error:' + $destination | out-file  \\server\share\logs\copyfilefailures.txt -append 
        }
}

Open in new window

0
 

Author Comment

by:nav2567
ID: 41777400
Thanks a lot David and Adam for always helping me!!!

Adam, I have been trying GPP - FILE update but I am not seeing the file is being copied to the destination.  

I specified \\server2\profiledir\%username%\appdata\roaming\vlc\vlc-qt-interface.ini in the destination of the GPP and the user login has r/w access.

The destination folder VLC is not created in \\server2\profiledir\%username%\appdata\roaming folder until the user launch VLC Player software the first time.  

Even the VLC folder is created in the roaming folder, I still do not see the file being copied after logout and log back in.   This is why I am going back to the legacy way and it works.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Uncontrolled local administrators groups within any organization pose a huge security risk. Because these groups are locally managed it becomes difficult to audit and maintain them.
Active Directory can easily get cluttered with unused service, user and computer accounts. In this article, I will show you the way I like to implement ADCleanup..
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses

649 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