Gathering data from share location

This topic contains 1 reply, has 2 voices, and was last updated by  Jonathan Warnken 10 months, 1 week ago.

  • Author
    Posts
  • #63655

    Venkata Kalyan
    Participant

    Hi,
    I wrote a script which will calculate the foldersize on local boxes of few servers and write to a csv file. The same way, I am trying to calculate foldersize from SAN location. Below is the script, can someone please help out where I am going wrong.

    foreach ($server in $opsservers){
    $servername = $server.column1
    $customers += @(Get-ChildItem -Path \\$servername\c$\inetpub\wwwroot\abc | select -expand Name)
    $customers = $customers -replace "`n|`r"
    foreach ($client in $customers){
    Write-Host "Working on $servername : $client..."
    $folders = Get-ChildItem -Path \\$servername\c$\inetpub\wwwroot\abc\$client\$client -Recurse | Measure-Object -property length -sum

    $foldersize = "{0:N2}" -f ($folders.sum / 1MB)

    $db = Get-ChildItem -Path \\cde\c$\Progra~1\Micros~1\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\$client*.mdf | Measure-Object -property length -sum
    $dbsize = "{0:N2}" -f ($db.sum / 1MB)

    $header = new-object psobject
    $header | Add-Member -membertype noteproperty -name "AppServer" -Value $servername.ToUpper()
    $header | Add-Member -membertype noteproperty -name "CustomerName" -Value $client.ToUpper()
    $header | Add-Member -membertype noteproperty -name "FolderSize(MB)" -Value $foldersize
    $header | Add-Member -membertype noteproperty -name "DBSize(MB)" -Value $dbsize
    $finalout += $header
    Write-Host "$servername : $client complete!"
    }
    }

    $finalout | export-csv C:\Users\venkatak\Desktop\Test\123_usage.csv -Encoding utf8 -NoTypeInformation

    ——- san folder location: \\sanprd\ops\prd\CustomerFiles\$client
    Where do i need to insert this command. I need to check the SAN folder, calculate the folder size and write to CSV file.

    -Kalyan

  • #63715

    Jonathan Warnken
    Participant

    you would update the path for this line

    $folders = Get-ChildItem -Path \\$servername\c$\inetpub\wwwroot\abc\$client\$client -Recurse | Measure-Object -property length -sum

    to

    $folders = Get-ChildItem -Path \\sanprd\ops\prd\CustomerFiles\$client -Recurse | Measure-Object -property length -sum

    But you need to verify that the rest of the logic in the script applies.

You must be logged in to reply to this topic.