powershell script for finding the total memory space of c driveEcho equivalent in PowerShell for script testingTerminating a script in PowerShellHow to run a PowerShell scriptPowerShell says “execution of scripts is disabled on this system.”What's the best way to determine the location of the current PowerShell script?How to pass an argument to a PowerShell script?List physical drive spaceColor-code cells in HTML mail based on criteriaPowershell progress bar vertical spacepowershell bitlocker won't unlock drive properly

Dropping outliers based on "2.5 times the RMSE"

Why the term 'unified' in "unified mass unit"?

As a DM, how to avoid unconscious metagaming when dealing with a high AC character?

What is the English equivalent of 干物女 (dried fish woman)?

How does one stock fund's charge of 1% more in operating expenses than another fund lower expected returns by 10%?

Modeling, view and projection transformation using vector and point in homogenous form

Can I play a first turn Simic Growth Chamber to have 3 mana available in the second turn?

download the bitcoin chain begining from a certain date

Help with understanding nuances of extremely popular Kyoto-ben (?) tweet

Why would an Inquisitive rogue choose to use Insightful Fighting as opposed to using their Cunning Action to Hide?

Supporting developers who insist on using their pet language

Is purchasing foreign currency before going abroad a losing proposition?

Is `curl something | sudo bash -` a reasonably safe installation method?

School House Points (Python + SQLite)

Hacker Rank : Electronics Shop

How to check the quality of an audio sample?

Why does java.time.Period#normalized() not normalize days?

Chaining Dissonant Whispers via War Caster feat

What to put after taking off rear stabilisers from child bicyle?

Does Google Maps take into account hills/inclines for route times?

A DVR algebra with weird automorphisms

Filtering fine silt/mud from water (not necessarily bacteria etc.)

Should you avoid redundant information after dialogue?

Find values of x so that the matrix is invertible



powershell script for finding the total memory space of c drive


Echo equivalent in PowerShell for script testingTerminating a script in PowerShellHow to run a PowerShell scriptPowerShell says “execution of scripts is disabled on this system.”What's the best way to determine the location of the current PowerShell script?How to pass an argument to a PowerShell script?List physical drive spaceColor-code cells in HTML mail based on criteriaPowershell progress bar vertical spacepowershell bitlocker won't unlock drive properly






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








-1















I want a PowerShell script to get the total memory space of C drive and used memory space in GB, if the total space is less than 200 GB it should print disk space is less than 200.



gwmi win32_logicaldisk | Format-Table DeviceId, MediaType, @n="Size";e=[math]::Round($_.Size/1GB,2),@n="FreeSpace";e=[math]::Round($_.FreeSpace/1GB,2)
$task=gwmi win32_logicaldisk | Format-Table DeviceId, MediaType, @n="Size";e=[math]::Round($_.Size/1GB,2),@n="FreeSpace";e=[math]::Round($_.FreeSpace/1GB,2)
if($task.Size -lt 200)

Write-Host "Hard Disk Space is less than 200."

else

Write-Host "Hard Disk Space is greater than 200."



I am getting all drive space on the above code, I need only C drive information and if condition is not working properly,Some one help me through this. Thanks in advance










share|improve this question






























    -1















    I want a PowerShell script to get the total memory space of C drive and used memory space in GB, if the total space is less than 200 GB it should print disk space is less than 200.



    gwmi win32_logicaldisk | Format-Table DeviceId, MediaType, @n="Size";e=[math]::Round($_.Size/1GB,2),@n="FreeSpace";e=[math]::Round($_.FreeSpace/1GB,2)
    $task=gwmi win32_logicaldisk | Format-Table DeviceId, MediaType, @n="Size";e=[math]::Round($_.Size/1GB,2),@n="FreeSpace";e=[math]::Round($_.FreeSpace/1GB,2)
    if($task.Size -lt 200)

    Write-Host "Hard Disk Space is less than 200."

    else

    Write-Host "Hard Disk Space is greater than 200."



    I am getting all drive space on the above code, I need only C drive information and if condition is not working properly,Some one help me through this. Thanks in advance










    share|improve this question


























      -1












      -1








      -1








      I want a PowerShell script to get the total memory space of C drive and used memory space in GB, if the total space is less than 200 GB it should print disk space is less than 200.



      gwmi win32_logicaldisk | Format-Table DeviceId, MediaType, @n="Size";e=[math]::Round($_.Size/1GB,2),@n="FreeSpace";e=[math]::Round($_.FreeSpace/1GB,2)
      $task=gwmi win32_logicaldisk | Format-Table DeviceId, MediaType, @n="Size";e=[math]::Round($_.Size/1GB,2),@n="FreeSpace";e=[math]::Round($_.FreeSpace/1GB,2)
      if($task.Size -lt 200)

      Write-Host "Hard Disk Space is less than 200."

      else

      Write-Host "Hard Disk Space is greater than 200."



      I am getting all drive space on the above code, I need only C drive information and if condition is not working properly,Some one help me through this. Thanks in advance










      share|improve this question
















      I want a PowerShell script to get the total memory space of C drive and used memory space in GB, if the total space is less than 200 GB it should print disk space is less than 200.



      gwmi win32_logicaldisk | Format-Table DeviceId, MediaType, @n="Size";e=[math]::Round($_.Size/1GB,2),@n="FreeSpace";e=[math]::Round($_.FreeSpace/1GB,2)
      $task=gwmi win32_logicaldisk | Format-Table DeviceId, MediaType, @n="Size";e=[math]::Round($_.Size/1GB,2),@n="FreeSpace";e=[math]::Round($_.FreeSpace/1GB,2)
      if($task.Size -lt 200)

      Write-Host "Hard Disk Space is less than 200."

      else

      Write-Host "Hard Disk Space is greater than 200."



      I am getting all drive space on the above code, I need only C drive information and if condition is not working properly,Some one help me through this. Thanks in advance







      powershell






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 26 at 5:44









      Vivek Kumar Singh

      2,3231 gold badge9 silver badges18 bronze badges




      2,3231 gold badge9 silver badges18 bronze badges










      asked Mar 26 at 5:43









      Ashwin KumarAshwin Kumar

      113 bronze badges




      113 bronze badges






















          2 Answers
          2






          active

          oldest

          votes


















          1














          You can use the Get-Volume cmdlet -



          if (((Get-Volume -DriveLetter C).Size)/1GB -lt 200)

          Write-Host "Hard Disk Space is less than 200."

          else

          Write-Host "Hard Disk Space is greater than 200."






          share|improve this answer






























            0














            if you need to run this test on win7 - even with ps5.1 - you can't use the Get-Volume cmdlet. [sigh ...] so here is one that uses CMI/WMI for that.



            what it does ...



            • sets a min free space threshold

            • uses the faster, non-deprecated CIM stuff to get the info on drive C:

            • only returns info if the C: drive meets the min freespace requirement

            • uses [string]::IsNullOrEmpty() to see if the result has any info in it

            • then uses an IF structure to decide what message to show

            • if space is too low, it uses the Write-Warning cmdlet for the nice orange text [grin]

            here's the code ...



            $MinFreeSpace_GB = 800

            $CDriveMinFree = [string]::IsNullOrEmpty((Get-CimInstance -ClassName CIM_LogicalDisk |
            Where-Object
            $_.DeviceID -eq 'C:' -and
            $_.FreeSpace -lt $MinFreeSpace_GB * 1GB
            ))

            if ($CDriveMinFree)

            'The C: drive has at least 0 GB free.' -f $MinFreeSpace_GB

            else

            Write-Warning ('Low free space on Drive C:!')



            output on my 600 GB free C: drive with the test threshold set to 800 ...



            WARNING: Low free space on Drive C:!





            share|improve this answer

























              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55350528%2fpowershell-script-for-finding-the-total-memory-space-of-c-drive%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              You can use the Get-Volume cmdlet -



              if (((Get-Volume -DriveLetter C).Size)/1GB -lt 200)

              Write-Host "Hard Disk Space is less than 200."

              else

              Write-Host "Hard Disk Space is greater than 200."






              share|improve this answer



























                1














                You can use the Get-Volume cmdlet -



                if (((Get-Volume -DriveLetter C).Size)/1GB -lt 200)

                Write-Host "Hard Disk Space is less than 200."

                else

                Write-Host "Hard Disk Space is greater than 200."






                share|improve this answer

























                  1












                  1








                  1







                  You can use the Get-Volume cmdlet -



                  if (((Get-Volume -DriveLetter C).Size)/1GB -lt 200)

                  Write-Host "Hard Disk Space is less than 200."

                  else

                  Write-Host "Hard Disk Space is greater than 200."






                  share|improve this answer













                  You can use the Get-Volume cmdlet -



                  if (((Get-Volume -DriveLetter C).Size)/1GB -lt 200)

                  Write-Host "Hard Disk Space is less than 200."

                  else

                  Write-Host "Hard Disk Space is greater than 200."







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 26 at 5:52









                  Vivek Kumar SinghVivek Kumar Singh

                  2,3231 gold badge9 silver badges18 bronze badges




                  2,3231 gold badge9 silver badges18 bronze badges























                      0














                      if you need to run this test on win7 - even with ps5.1 - you can't use the Get-Volume cmdlet. [sigh ...] so here is one that uses CMI/WMI for that.



                      what it does ...



                      • sets a min free space threshold

                      • uses the faster, non-deprecated CIM stuff to get the info on drive C:

                      • only returns info if the C: drive meets the min freespace requirement

                      • uses [string]::IsNullOrEmpty() to see if the result has any info in it

                      • then uses an IF structure to decide what message to show

                      • if space is too low, it uses the Write-Warning cmdlet for the nice orange text [grin]

                      here's the code ...



                      $MinFreeSpace_GB = 800

                      $CDriveMinFree = [string]::IsNullOrEmpty((Get-CimInstance -ClassName CIM_LogicalDisk |
                      Where-Object
                      $_.DeviceID -eq 'C:' -and
                      $_.FreeSpace -lt $MinFreeSpace_GB * 1GB
                      ))

                      if ($CDriveMinFree)

                      'The C: drive has at least 0 GB free.' -f $MinFreeSpace_GB

                      else

                      Write-Warning ('Low free space on Drive C:!')



                      output on my 600 GB free C: drive with the test threshold set to 800 ...



                      WARNING: Low free space on Drive C:!





                      share|improve this answer



























                        0














                        if you need to run this test on win7 - even with ps5.1 - you can't use the Get-Volume cmdlet. [sigh ...] so here is one that uses CMI/WMI for that.



                        what it does ...



                        • sets a min free space threshold

                        • uses the faster, non-deprecated CIM stuff to get the info on drive C:

                        • only returns info if the C: drive meets the min freespace requirement

                        • uses [string]::IsNullOrEmpty() to see if the result has any info in it

                        • then uses an IF structure to decide what message to show

                        • if space is too low, it uses the Write-Warning cmdlet for the nice orange text [grin]

                        here's the code ...



                        $MinFreeSpace_GB = 800

                        $CDriveMinFree = [string]::IsNullOrEmpty((Get-CimInstance -ClassName CIM_LogicalDisk |
                        Where-Object
                        $_.DeviceID -eq 'C:' -and
                        $_.FreeSpace -lt $MinFreeSpace_GB * 1GB
                        ))

                        if ($CDriveMinFree)

                        'The C: drive has at least 0 GB free.' -f $MinFreeSpace_GB

                        else

                        Write-Warning ('Low free space on Drive C:!')



                        output on my 600 GB free C: drive with the test threshold set to 800 ...



                        WARNING: Low free space on Drive C:!





                        share|improve this answer

























                          0












                          0








                          0







                          if you need to run this test on win7 - even with ps5.1 - you can't use the Get-Volume cmdlet. [sigh ...] so here is one that uses CMI/WMI for that.



                          what it does ...



                          • sets a min free space threshold

                          • uses the faster, non-deprecated CIM stuff to get the info on drive C:

                          • only returns info if the C: drive meets the min freespace requirement

                          • uses [string]::IsNullOrEmpty() to see if the result has any info in it

                          • then uses an IF structure to decide what message to show

                          • if space is too low, it uses the Write-Warning cmdlet for the nice orange text [grin]

                          here's the code ...



                          $MinFreeSpace_GB = 800

                          $CDriveMinFree = [string]::IsNullOrEmpty((Get-CimInstance -ClassName CIM_LogicalDisk |
                          Where-Object
                          $_.DeviceID -eq 'C:' -and
                          $_.FreeSpace -lt $MinFreeSpace_GB * 1GB
                          ))

                          if ($CDriveMinFree)

                          'The C: drive has at least 0 GB free.' -f $MinFreeSpace_GB

                          else

                          Write-Warning ('Low free space on Drive C:!')



                          output on my 600 GB free C: drive with the test threshold set to 800 ...



                          WARNING: Low free space on Drive C:!





                          share|improve this answer













                          if you need to run this test on win7 - even with ps5.1 - you can't use the Get-Volume cmdlet. [sigh ...] so here is one that uses CMI/WMI for that.



                          what it does ...



                          • sets a min free space threshold

                          • uses the faster, non-deprecated CIM stuff to get the info on drive C:

                          • only returns info if the C: drive meets the min freespace requirement

                          • uses [string]::IsNullOrEmpty() to see if the result has any info in it

                          • then uses an IF structure to decide what message to show

                          • if space is too low, it uses the Write-Warning cmdlet for the nice orange text [grin]

                          here's the code ...



                          $MinFreeSpace_GB = 800

                          $CDriveMinFree = [string]::IsNullOrEmpty((Get-CimInstance -ClassName CIM_LogicalDisk |
                          Where-Object
                          $_.DeviceID -eq 'C:' -and
                          $_.FreeSpace -lt $MinFreeSpace_GB * 1GB
                          ))

                          if ($CDriveMinFree)

                          'The C: drive has at least 0 GB free.' -f $MinFreeSpace_GB

                          else

                          Write-Warning ('Low free space on Drive C:!')



                          output on my 600 GB free C: drive with the test threshold set to 800 ...



                          WARNING: Low free space on Drive C:!






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 26 at 6:09









                          Lee_DaileyLee_Dailey

                          3,6582 gold badges8 silver badges12 bronze badges




                          3,6582 gold badges8 silver badges12 bronze badges



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55350528%2fpowershell-script-for-finding-the-total-memory-space-of-c-drive%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                              SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                              은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현