Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

path with wildcard

Posted on 2016-11-08
3
Medium Priority
?
57 Views
Last Modified: 2016-11-08
How can I use a wildcard in a path name?  Java is always updating and I need to be able to copy files into the java security folder but I dont want to have to keep updating the path name for every version.  How can I use a wildcard for a folder in the path.
The dirtory is C:\Program Files (x86)\Java\jre1.8.0_111\lib\security

Here is what I have tried.
copy-item c:\test.txt "C:\Program Files (x86)\Java\jre*\lib\security"
0
Comment
Question by:Roccat
  • 2
3 Comments
 
LVL 85

Accepted Solution

by:
oBdA earned 2000 total points
ID: 41878898
In test mode; remove the -WhatIf at the end to run it for real:
Get-ChildItem 'C:\Program Files (x86)\Java\jre*' -Directory | % {Copy-Item -Path 'C:\test.txt' -Destination "$($_.FullName)\lib\security" -WhatIf}

Open in new window

1
 

Author Closing Comment

by:Roccat
ID: 41878920
Thank you!
0
 

Author Comment

by:Roccat
ID: 41878935
In case anyone else is looking to do what I am doing this is it.
Get-ChildItem 'C:\Program Files (x86)\Java\jre*'  -Directory | % {Copy-Item -Path 'local_policy.jar' -Destination "$($_.FullName)\lib\security" -force}
Get-ChildItem 'C:\Program Files (x86)\Java\jre*'  -Directory | % {Copy-Item -Path 'US_export_policy.jar' -Destination "$($_.FullName)\lib\security" -force}
0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  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

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Loops Section Overview

916 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