?
Solved

specify a PS script in group policy.

Posted on 2016-08-30
4
Medium Priority
?
41 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 82

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 42

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 82

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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
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.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

762 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