I am creating a VBS in php that is being saved to a remote server on the network, I am then creating a powershell script to run it and executing from PHP.
$ITIMHOS = "ABD-DEF-123";
//create the ps1
$fs = fopen("\\\\spc-nsa-001\\nscap\\RunVBS.ps1","a"); //create batch file
fwrite($fs,"Start-Process cmd.exe /c'\\\\spc-nsa-001\\nscap\\JP-Computer-import-".$ITIMHOS.".vbs'"); //write batch file contents
fclose($fs);
the VBS has to be run on that remote server which is why I'm doing it this way, and it has to be run by a specific user and that's what i'm having trouble with. I currently use this:
$psRun = '\\\\spc-nsa-001\\c$\\windows\\syswow64\\WindowsPowerShell\\v1.0\\powershell.exe'; //64bit server, 32bit web server
$ps1File = '\\\\spc-nsa-001\\nscap\\runVBS.ps1';
exec($psRun.' -command '.$ps1File);
Can anyone advise/help with how I can run it with a different user (DOMAIN\user.name, P4$$word)