Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: At a loss with Get-ChildItem behavior

$
0
0

What’s in your $logName variable when it works, an when it does not?

I suspect that the problem is that you’ve declared the $logName parameter as a [string], not [string[]]. When you want to pass multiple multiple values to the -Include parameter of Get-ChildItem, you do so by passing it an array of strings. Even if you’re passing an array to your Copy-WebLogs function, PowerShell is converting that into a single String object because of how you declared $logName in your param block (which typically means you’ll have a space-separate list, as seen here:)

$variable = [string]('One','Two','Three','Four','Five')
$variable.GetType().FullName

$variable

<#
Output:

System.String
One Two Three Four Five
#>

Viewing all articles
Browse latest Browse all 13067

Trending Articles