Powershell calculated property not working when integrated with the ForEach loop

Welcome Forums General PowerShell Q&A Powershell calculated property not working when integrated with the ForEach loop

Viewing 1 reply thread
  • Author
    Posts
    • #254336
      Participant
      Topics: 27
      Replies: 28
      Points: 250
      Rank: Participant

      Hi Folks,

      I need some help in tweaking or adjusting the below Powershell script to gather and collect the Top 32 biggest files and its total size from multiple different large file servers.

      The Server name is populated from $_.ComputerName variable.
      The Directory path for each of the servers is different as per $_.ContentPath variable

      I have tested the below in each Remote Desktop session to the server, and opening Powershell ISE, both script returns the numbers correctly, although waiting for 4-5 hours.

      Script 1 Using GCI, throws thousands of error on the screen due to 260 characters limit:

      Script 2 Using Robocopy:

      Combined script to check which method works consistently:

      <u>Problem</u>: both of the column Top 32 Largest Files Size – GCI and Top 32 Largest Files Size – Robocopy only shows the first two servers, while the rest is just 0 and empty. No error throws out, apart from the 260 characters limit.

      However, when using the below-combined script as Calculated property, the script just returning the first two servers, not 10+ DFS File servers I have globally.
      each of the servers has about 2-3 million files, hence I am using the Integer64 [long].

      Any help would be greatly appreciated.

      Thank you in advance.

    • #254354
      Participant
      Topics: 7
      Replies: 2458
      Points: 6,439
      Helping Hand
      Rank: Community MVP

      When you crosspost the same question at the same time to different forums you should at least post links to the other forums along with your question to avoid people willing to help you making their work twice or more.

      https://stackoverflow.com/questions/63705878/powershell-calling-robocopy-to-get-top32-largest-files-total-size-not-working

      Thanks

Viewing 1 reply thread
  • You must be logged in to reply to this topic.