Powershell Script assistance required -
i'm piping file's contents select-object , creating 2 properties each name, computername
, fileexists
, latter value result of test-path
get-content c:\users\admin\documents\scripts\serverlist.txt | ` select-object @{name='computername';expression={$_}},@{name='folderexist';expression={ test-path "\\$_\c$\data\repository"}}, @{name='size';expression={$_.sum}}
i want return size of folder if exists on each server. how ?
tried adding
@{name='size';expression={$_.sum}}
to select-object
not return value
i think looking for
get-content c:\users\admin\documents\scripts\serverlist.txt | select-object @{name='computername';expression={$_}},@{name='folderexist';expression={ test-path "\\$_\c$\data\repository"}}, @{name='size';expression={ "{0:n2}" -f ((gci -path "\\$_\c$\data\repository" -recurse | measure-object -property length -sum).sum /1mb) + " mb" }}
Comments
Post a Comment