I am writing scripts to monitor disk usage based on scripts from msdn code gallery:
https://social.technet.microsoft.com/Forums/scriptcenter/en-US/1a1e47c2-635f-4572-a556-e0d6cc964af8/how-to-analyze-the-powershell-console-output-with-tools-such-as-excel-and-access-etc?forum=ITCG#c8d40235-deae-4a15-9d51-9d0f89d7f0a5
I need to execute the script on multiple servers with PowerShell remote session. One of the problem I got is that it looks like ParameterSetName does not work with ArgumentList.
What follows is the simple test script I used. it's based on the parameter definition of Get-DirStats.ps1, I just added positions for Switch parameters because I don't know how to pass named parameter with ArgumentList.
[CmdletBinding(DefaultParameterSetName="Path")]
param(
[parameter(Position=0,Mandatory=$false,ParameterSetName="Path",ValueFromPipeline=$true)]
$Path=(get-location).Path,
[parameter(Position=0,Mandatory=$true,ParameterSetName="LiteralPath")]
[String[]] $LiteralPath,
[parameter(Position=1,Mandatory=$false)]
[Switch] $Only,
[parameter(Position=2,Mandatory=$false)]
[Switch] $Every,
[parameter(Position=3,Mandatory=$false)]
[Switch] $FormatNumbers,
[parameter(Position=4,Mandatory=$false)]
[Switch] $Total
)
Write-host "ParameterSetName:" $PSCmdlet.ParameterSetName
Write-host "Path:" $Path
Write-host "LiteralPaht:" $LiteralPath
Write-host "Only:" $Only
What follows in the screenshot for test result:

Another related issue is I use Get-ChildItem2 to overcome the 260 character limit in path. It does not work in powershell remote session for me. I asked the question https://gallery.technet.microsoft.com/scriptcenter/Get-ChildItemV2-to-list-29291aae/view/Discussions