The first approach was using Invoke-Command of a ScriptBlock supplying the Credential and specifying localhost as the ComputerName. I got some errors related to localhost and abandoned the approach.
Now I am trying to use Start-Job to run the ScriptBlock. I am seeing some behavior that I don't understand.
Here's some sample code that just adds a line to file. For now, I'm not even providing credentials for another account.
# A quick sample Start-Job, will in work when packaged?
$SB={
$date=Get-Date -format d
$time=(Get-Date).ToLongTimeString()
$Mes=$date+" "+$time+": The Start-Job ran and worked"
Add-Content -Path "C:\SystemsTeam\Scripts\ConfigureTablet\ConfigureTablet_log.log" -Value $Mes
}
$SBJob=Start-Job -ScriptBlock $SB
When Run from PowerShell Studio, it DOES NOT work (i.e., the job appears not to run because no content is added). When Run-in-console from PowerShell Studio, it DOES appear to work. From a packaged EXE, it DOES NOT work.
PowerShell Code
Double-click the code block to select all.. I'm sure that this must be some simple contextual problem. Can someone please set me straight? Then I can move on to using credentials, packaging, etc. Thanks, Andy