I am new to PowerShell scripting your help will be really appreciated!
The following works for me by running it as .ps1 script:
$source="C:\Backup\Full\" Get-ChildItem $source -Recurse -filter "aaa_bbb_client_FULL.txt"
The following does not work for me by running it as .ps1 script:
$client="sclient" $source="C:\Backup\Full\" Get-ChildItem $source -Recurse -filter "aaa_bbb_" + $client + "_FULL.txt"
error I am getting:
Please help me to understand what I am missing.
well, you've put "sclient" into the second example, whereas the first used "client". But, you don't need to concatenate:
Ought to give the same result.
Get-ChildItem $source -Recurse -filter (“aaa_bbb_” + $client + “_FULL.txt”)
Filter expects a single string to define the filter criteria. Using + (concatenation) it only looks at the first string and treats the rest as different parameters
Thank you so much for your help!!!! It worked.
Sorry for typo
The following worked!!!
Get-ChildItem $source -Recurse -filter “aaa_bbb_$($client)_FULL.txt”
You must be logged in to reply to this topic.