Quantcast
Channel: SAPIEN Forums
Viewing all articles
Browse latest Browse all 427

PowerShell • Concatenate two strings as $progressbar name

$
0
0
Hi,

In a loop I'm trying to concatenate two strings to be used as progressbar name to set (for each progressbar) the maximum value (from a counter):

My progressbar names are $progressbarDesktop, $progressbarFavorites, etc...

Code:

$folders = @("Desktop", "Favorites", "Documents", "Pictures", "Music", "Downloads", "Videos")foreach ($Folder in $folders){$count= (Get-ChildItem -File -Path "C:\Users\John Doe\$folder" -recurse -attributes !H | Measure-Object).Count$progressbar = '$progressbar' + $folder$progressbar.Maximum = $count}
But it does not work... ERROR: Method invocation failed because [System.String] does not contain a method named 'Maximum'.

How can do in a loop ?

Thanks for your help ! (despite my bad english)

Statistics: Posted by BiocefBiocef — Wed Jun 12, 2024 5:06 am



Viewing all articles
Browse latest Browse all 427

Trending Articles