Quantcast
Viewing all articles
Browse latest Browse all 122

How to add Double quotes to Array elements in Powershell console?

I need to display all elements of the $FileNames array in Powershell console. I am iterating in a For loop but i cant print double quotes to all Array index elements on the console. Please help.

Actual Result:Dropped file:- "$FileNames[$i]" successfully into the folder

Expected Result with Double quotes(for every filename in the array):Dropped file:- "NewFile1.txt" successfully into the folder... and so on.

$FileNames = @(Get-ChildItem $TestFolder\*.txt | Select-Object -ExpandProperty Name)         For($i=0;$i -lt $FileNames.count;$i++)        {                if($FileNames[$i] -eq $fileName)            {                $filePathNew = $TestFolder + $FileNames[$i]                Copy-Item -Path $filePathNew -Destination $RemoteURLFolder\$FolderName -Recurse                 Write-Host "=> Dropped file:- "'"$FileNames[$i]"'" successfully into the folder ""

Viewing all articles
Browse latest Browse all 122

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>