0

I am looking for a PS script which will search for a particular file name and check its existence. If file exists it should execute a batch command.

$version = "1.1.0"
$packageName = "example.DTO.$version"
Get-ChildItem "d:\Test" | Where-Object { $_.Name -match "$packageName.nupkg" }

and my batch command

C:\NugetRestore\nuget.exe push "d:\Test\$packageName.nupkg" saranuget -Source "http://123.456.78.90/myget" -Timeout 120

I am unable to integrate both this.

1
  • 1
    What have you tried, and how has what you've tried failed? SO is not a code-writing service; the best questions are those which provide useful information so that those who answer can guide you to devising your own correct answer. See How to Ask a Good Question. Commented Mar 28, 2017 at 12:03

1 Answer 1

1

This covers where the test matches multiple files:

$version = "1.1.0"
$packageName = "example.DTO.$version"
$FileCheck = Get-ChildItem "d:\Test" | Where-Object { $_.Name -match "$packageName.nupkg" }

$FileCheck | ForEach-Object {
    C:\NugetRestore\nuget.exe push "$($_.Fullname)" saranuget -Source "http://123.456.78.90/myget" -Timeout 120
}
Sign up to request clarification or add additional context in comments.

Comments

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.