From 32fa5e9f92baaa8a2863d4f2e88c8169039d6845 Mon Sep 17 00:00:00 2001 From: Matt Kotsenas Date: Wed, 27 May 2020 14:49:49 -0700 Subject: [PATCH] Fix parentheses when running script block immediately Creating a script block to pass to `Invoke-Command` needs another set of parentheses, otherwise PowerShell gives the parse error: ```powershell Invoke-Command: Cannot bind parameter 'ScriptBlock'. Cannot convert the "[scriptblock]::Create" value of type "System.String" to type "System.Management.Automation.ScriptBlock". ``` --- Undo-WinRMConfig.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Undo-WinRMConfig.ps1 b/Undo-WinRMConfig.ps1 index d49f569..ace111e 100644 --- a/Undo-WinRMConfig.ps1 +++ b/Undo-WinRMConfig.ps1 @@ -114,7 +114,7 @@ Function Setup-Undo { If ($RunImmediately) { Write-Output 'Undoing WinRM Config Right Now (do NOT execute this over remoting or this code will not complete)...' - Invoke-Command -ScriptBlock [Scriptblock]::Create($UndoWinRMScript) + Invoke-Command -ScriptBlock ([Scriptblock]::Create($UndoWinRMScript)) exit 0 } else