ISE vs powershell - 'ScriptBlock'. The argument is null

Welcome Forums General PowerShell Q&A ISE vs powershell - 'ScriptBlock'. The argument is null

This topic contains 1 reply, has 1 voice, and was last updated by

6 months, 3 weeks ago.

  • Author
  • #103462

    Points: 1
    Rank: Member

    Hi guys

    first time poster so please excuse any bad formatting!!

    really strange one – i have a very simple script:-

    Install-Module -Name SpeculationControl -Force

    $vms = Get-ADComputer -Filter {(operatingsystem -like "*Server*") -and (enabled -eq $true)} -SearchBase "dc=xxx,dc=com" | Select Name

    $result = foreach ($vm in $vms) {Invoke-Command -ComputerName $ ${function:Get-SpeculationControlSettings}}

    i currently can run this in an ISE window and it goes through all vm's successfully but when i go to run in powershell i get the below error:-

    Invoke-Command : Cannot validate argument on parameter 'ScriptBlock'. The argument is null. Provide a valid value for the argument, and then try running
    the command again.
    At line:1 char:72
    + ... nd -ComputerName $ ${function:Get-SpeculationControlSettings}}
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidData: (:) [Invoke-Command], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeCommandCommand

    even more strage is when i open up another ISE program i get the above error.

    im sure something very simple...please help

    thanks in advance

  • #103469

    Points: 1
    Rank: Member

    ignore me – id not imported active-directory module...doh

The topic ‘ISE vs powershell - 'ScriptBlock'. The argument is null’ is closed to new replies.