What used to work in my script doesn't anymore and I am out of ideas.
I'm trying to do the following:
Import-Module 'H:\folder\folder1\Remove-Software.psm1'
$sessionoption = New-PSSessionOption -SkipCACheck -SkipCNCheck
$s = New-PSSession -ComputerName $Global:DevicePrimaryIP -Credential $Global:Creds -SessionOption $sessionoption
Invoke-Command -Session $s -ScriptBlock $function:RemoveSoftware
This should log into the remote software and remove software, however I keep receiving the following 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:41
Also, I've tried every combination for the scriptblock I can think of.
I've changed things elsewhere in my script but haven't touched this for some time. If anyone else can see the problem anyhelp would be appreciated.
RemoveSoftwarein your script. - Ansgar Wiechersfunction removesoftware{ kill process delete directory return "software has been removed" }- Mike$function:removesoftwarealone? Just to see that the function is defined - Frode F.