Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Handling parameters on a single line script

$
0
0

Hi all

I have a single line of Powershell which spiders through all the sub directories of the current directory and returns a nice report giving the disk space used by each sub folder. 

I want to edit the script so that I can prompt the user for the directory to target. 

I need to keep the script as a single line because we use a remote management tool which, oddly, only allows one line for its remote powershell execution. 

My script is currently 

  gci .|%{$f=$_; gci -r $_.FullName| measure-object -property length -sum | select  @{Name="Name";Expression={$f}},@{Name="Sum (MB)";Expression={"{0:N3}"-f ($_.sum /1MB)}},Sum}| sort Sum-desc | format-table -PropertyName,"Sum (MB)",Sum-autosize

Any ideas how this can be done? I can hack it to work in a ps1 script but I can't actually use that here. 

Olly


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>