Try something like this:

Get-PsDrive C |select-object Free|ConvertTo-json

You should then be able to use 'register' to capture the result and make 
use of it.

By the way I found this which has a lot of good starting points for 
converting unix toolbox commands into powershell 
 
https://www.gitbook.com/book/devopscollective/a-unix-person-s-guide-to-powershell/details

Hope this helps,

Jon



On Wednesday, July 13, 2016 at 12:06:44 PM UTC+1, ishan jain wrote:
>
> I am trying very hard to get a numerical value of free disk space on a 
> windows server 2012 R2 machine, but couldn't get it so far. All the 
> commands that are available for listing the disk space information - they 
> are not providing the output in proper format. Here are a few commands i 
> tried:
>
> *raw: Get-PSDrive C | Select-Object Free*
>
> *Output:*
>
> TASK [debug] 
> *******************************************************************
> ok: [AC05] => {
>     "freeSpace": {
>         "changed": false,
>         "rc": 0,
>         "stderr": "",
>         "stdout": "\r\n                                                   
>                         Free\r\n                                           
>                                 ----\r\n                                   
>                                  53051551744\r\n\r\n\r\n",
>         "stdout_lines": [
>             "",
>             "                                                             
>               Free",
>             "                                                             
>               ----",
>             "                                                             
>        53051551744",
>             "",
>             ""
>         ]
>     }
> }
>
>
> *raw: fsutil volume diskfree C: | find /i "avail free bytes"*
>
> *output:*
>
> TASK [debug] 
> *******************************************************************
> ok: [AC05] => {
>     "drive": {
>         "changed": false,
>         "rc": 0,
>         "stderr": "",
>         "stdout": "Total # of avail free bytes  : 53056536576\r\n",
>         "stdout_lines": [
>             "Total # of avail free bytes  : 53056536576"
>         ]
>     }
> }
>
> wmic logicaldisk get size
>
> output: (no way of getting info for single drive)
>
> Size
>
> 63899168768
>
> 53683941376
>
>
> ------------------
>
>
> As you can see, there really doesn't seems to be a way of knowing the 
> exact numerical value of free disk space in windows machine. Anybody doing 
> this without using any external utility ?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/63adcfdd-85a7-4f9a-ac90-bc3bcfb569b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to