Adding a string to a list returns the length of the string

I am a beginner at Powershell. I have a script that I’m using to copy a file to a list of computers.

The problem I’m running into is that when I add a string representing a computer name to the list ends up being a number that is the length of the string.

Here is a copy of the script:

$csv = Import-Csv “C:\Users\michaelk\Downloads\staffcomputers.txt”
$Source = “c:\keeper\KeeperPasswordManager.appinstaller”
$dest = “C$\Keeper”
$Output = “C:\Keeper\missingworkstations.csv”
$Items = New-Object System.Collections.Generic.List[System.Object]

#reads .csv for workstation NAME.
foreach ($line in $csv)
#pings each Host. If true, Copy file.
if (Test-Connection $line.Name -count 1 -quiet)
write-Host “true”, $line.Name
$name = “\” + $line.Name + “\C$\keeper”

      #copies the file over to target machine
      new-Item -Path "$name" -ItemType Directory -Force
	  Copy-Item -path $Source -Destination $name

#if ping fails, log which workstation and that workstation’s IP in a new CSV.
write-host “false”, $line.Name
#exports array of workstations that were unreachable for manual processing at a later date.
$items | Export-Csv -NoTypeInformation -Path $Output

Where the last Write-Host it returns the actual name of the computer, but then on the next line I get the length of the string. How can I fix this?

Welcome to the forum. :wave:t4:

When you post code or sample data or console output please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.
Thanks in advance

Something like this shouild work actually.

$csv = Import-Csv -Path 'C:\Users\michaelk\Downloads\staffcomputers.txt'
$Source = 'c:\keeper\KeeperPasswordManager.appinstaller'
$Output = 'C:\Keeper\missingworkstations.csv'
$Items = New-Object System.Collections.Generic.List[System.Object]

foreach ($line in $csv) {
    if (Test-Connection $line.Name -count 1 -quiet) {
        $name = '\\{0}\C$\keeper' -f $line.Name 
        New-Item -Path $name -ItemType Directory -Force | Out-Null
        Copy-Item -path $Source -Destination $name
    else {
$items | Export-Csv -Path $Output -NoTypeInformation