Trying to create a table via Powershell

Welcome Forums General PowerShell Q&A Trying to create a table via Powershell

Viewing 3 reply threads
  • Author
    Posts
    • #232108
      Participant
      Topics: 1
      Replies: 1
      Points: 35
      Rank: Member

      Hi Guys, I do have bunch of target folders that I’m trying to check them regularly via PS script;

      Z:\RootFolder\AAAA0001\Apps\…
      Z:\RootFolder\BBBB0001\Apps\…
      Z:\RootFolder\CCC00001\Apps\…
      Z:\RootFolder\DDDD0001\Apps\…
      goes on

      I wanna make get an output something like this

      Ref                     AppFolderSize(GB)
      AAAA0001      3GB
      BBBB0001      2GB
      CCCC0001      5GB
      DDDD0001    8GB
      etc.

      Has someone done this?

    • #232123
      Participant
      Topics: 5
      Replies: 2384
      Points: 6,066
      Helping Hand
      Rank: Community MVP

      Michael, welcome to Powershell.org. Please take a moment and read the very first post on top of the list of this forum: Read Me Before Posting! You’ll be Glad You Did!.

      When you post code, error messages, sample data or console output format it as code, please.
      In the “Text” view you can use the code tags “PRE“, in the “Visual” view you can use the format template “Preformatted“. You can go back edit your post and fix the formatting – you don’t have to create a new one.
      Thanks in advance.

      This forum is for scripting questions rather than script requests. We do not write customized and ready to use scripts or solutions on request.

      What have you tried so far? We expect you to make an own attempt to get your task done or to solve your problem. If you have done so already please document here what exactly you have done and show your code. Then we probably might be able to help you step further.

      Has someone done this?

      That’s such a basic question that I wonder why you even spend the effort to create an account in a forum and ask a question. You could have find a solution by google-ing in a matter of seconds.

    • #232183
      Participant
      Topics: 1
      Replies: 1
      Points: 35
      Rank: Member

      What I’ve don so far is just draft codes, couldn’t figure out how to do it really,

       

      $companies = “Z:\RootFolder”
      $folders = Get-ChildItem -Path $companies -Exclude Backup,Robocopy -Directory -Name -Force -ErrorAction SilentlyContinue

      foreach {
      Write-Host $_.Name

      }

      | ForEach-Object {ls “$companies\$_.Name\Apps”}

      -Process {{dir $_Name} {“{0:N2} GB” -f (gci $_Name -Recurse | measure Length -s).sum / 1Gb)}}

      {“{0:N2} GB” -f ((gci “$companies\$_Name\Apps” -Recurse | measure Length -s).sum / 1Gb)}

      | ForEach-Object -Process {“{0:N2} GB” -f ((gci $_Name -Recurse | measure Length -s).sum / 1Gb)}

      $companies = “Z:\RootFolder”
      “{0:N2} GB” -f ((gci “$companies\BBBB0001\Apps” -Recurse | measure Length -s).sum / 1Gb)

      “{0:N2} GB” -f ((gci -Recurse | measure Length -s).sum / 1Gb)

    • #232186
      Participant
      Topics: 5
      Replies: 2384
      Points: 6,066
      Helping Hand
      Rank: Community MVP

      I had described how you should format code. Please go back and fix your code formatting. Please do not create a new post – change your existing one.

      If your code results in errors you should post them as well, please.

Viewing 3 reply threads
  • You must be logged in to reply to this topic.