Hope you can help me with a problem trying to execute a script block with alternate credentials on a local computer. I've been thoroughly searching on forums and doing some googling and found two possible approach to solve my problem:
- Use Invoke-Command
- Use Start-Job
Using approach #1 I had this code:
$res = Invoke-Command -Credential $migratorCreds -ScriptBlock {param($one, $two) Get-LocalUsers -parentNodeXML $one -migratorUser $two } -ArgumentList $xmlPRE,$migratorCreds
where Get-LocalUsers
is a custom function stored in a custom module (*.psm1).
My problem is that every time I run this code I get following error:
Parameter set cannot be resolved using the specified named parameters
So it's obvious that I must be missing something, could you help me on this topic?
Thanks in advance...
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…