0

I want to make a script for my users. It will let us install applications while there are not admins.

pw= get-content \\xxx\xxxx\xxx\xxx\pass.txt | convertto-securestring
$pp= new-object -typename System.Management.Automation.PSCredential -argumentlist "xx\admin",$pw

The file is created and is crypted.

$script = "\\xxxx\xxx\xxx\xxx\Install_chrome.ps1"
Start-Process powershell -Credential $pp -ArgumentList '-noprofile -command &{Start-Process $script -verb runas}' -RedirectStandardOutput c:\stdout.txt -RedirectStandardError c:\stderr.txt

Here's my error:

Start -Process : Unable to validate the argument on parameter "FilePath". The argument is null or empty. Specify an argument that is not null or empty and try again.

mikus
  • 3,042
  • 1
  • 30
  • 40
Alex Lum
  • 175
  • 2
  • 12
  • 2
    `Start-Process powershell` essentially starts [a new session with its own variable scopes](https://technet.microsoft.com/en-us/library/hh847849.aspx). You need to move the `$script = ...` line into the script block that you pass to the `-Command` parameter. Of course, security implications of storing admin password in a plaintext file are another matter entirely. ( – Alexander Obersht Oct 05 '15 at 16:10
  • 1
    Off-topic but if your issue is: _install[ing] applications while there are not admin[s]_ then you could use free software like PDQ Deploy that will do this for you without storing administrative passwords which is a no no. – Matt Oct 05 '15 at 16:30

0 Answers0