0

I have a folder containing a large list of hofixes. Each hotfix filename contains the KB number such as KB2993958 similar to Windows8.1-KB2957189-x64.msu

I'm trying to troubleshoot an issue caused by the installation of a particular hotfix. I have narrowed the selection down to about 50 possible hotfixes, far less than how many are contained in the master folder. I want to install 10 hotfixes at a time to try and isolate the issue.

I have the list of 50 hotfixes I need to install either in a get-hotfix object or probably converted to a string in a variable.

So I want to compare the Kb numbers listed in my object / variable against the file names in the master folder and if the file name contains any of the KB number stored in my variable then move this file into a folder, ready for installation.

Seems simple, but I can't work it out.

1
  • 1
    Please post your attempts so far and a sample of the data you're working with. See this page Commented Sep 11, 2015 at 15:16

1 Answer 1

2

Use Get-ChildItem with a filter that contains the KB ID, and pipe it to Move-Item.

$s = "KB2957189"
$HfPath = "c:\temp\"
$MoveToPath = "c:\temp\temp1\"

get-childitem -path $HfPath -Filter "*$s*" | Move-Item -Destination $MoveToPath
Sign up to request clarification or add additional context in comments.

2 Comments

Please avoid code-only answers (or at least add inline comments)
@MathiasR.Jessen Aren't there some situations where a code-only answer is the best answer, e.g. when the question is very clear?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.