Solved

specify a PS script in group policy.

Posted on 2016-08-30
4
36 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 80

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 40

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 80

Accepted Solution

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

740 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