Space command one-liner, output in GB?

by JB3 at 2012-09-07 11:17:46

Hey all, new to the forum but have lurked for a while.

I use a space command to get files over 100MB, but I really want to display this info in GB. / 1GB does not seem to work properly, any ideas?

Here is the command I use:
gci c:\ -rec | where {$.Length -gt 100mb}
by willsteele at 2012-09-07 11:35:13
You can add a select statement after your where cmdlet and create an expression within your select to get you in the ballpark.

gci c:\ -rec | where {$
.Length -gt 100mb} | select mode, lastwritetime, @{e={"{0:0}GB" -f ($_.length/1gb)};l=‘Length’}, Name
by JB3 at 2012-09-07 11:53:32
Thanks Will, worked perfectly to my needs, also worked when changed to MB. Where would I add the -comp computername in the statement to run this on a remote server?
by DonJ at 2012-09-07 11:59:33
GCI doesn’t have a -computerName parameter. You can use it with a UNC path (like \SERVER\SHARE\FOLDER). If the remote machine has PowerShell Remoting enabled, then you’d send the entire command to it via Invoke-Command.