Solved

specify a PS script in group policy.

Posted on 2016-08-30
4
27 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
  • 2
4 Comments
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
Comment Utility
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 38

Expert Comment

by:Adam Brown
Comment Utility
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 78

Accepted Solution

by:
David Johnson, CD, MVP earned 500 total points
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
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…
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 to another domain controller. Log onto the new domain controller with a user account t…

763 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

11 Experts available now in Live!

Get 1:1 Help Now