Skip to content

Instantly share code, notes, and snippets.

@pronichkin
Created September 17, 2019 15:56
Show Gist options
  • Save pronichkin/d881373d368c7f01767f3021685bd822 to your computer and use it in GitHub Desktop.
Save pronichkin/d881373d368c7f01767f3021685bd822 to your computer and use it in GitHub Desktop.
Shows an issue with SwitchParameter in ScriptBlock when execute remotely
[System.Management.Automation.ScriptBlock]$ScriptBlock = {
[cmdletBinding()]
Param(
[Parameter(
Mandatory = $False
)]
[ValidateNotNullOrEmpty()]
[System.Management.Automation.SwitchParameter]
# [System.Boolean]
$Force
)
Process
{
"Force: $Force"
}
}
Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $False #-ComputerName 'server.corp.contoso.com'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment