Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Ветеран


Сообщения: 1259
Благодарности: 861

Профиль | Отправить PM | Цитировать


Несколько вариантов:

1) Использовать psexec , где можно указать пароль и логин.

-u Specifies optional user name for login to remote
computer.
-p Specifies optional password for user name. If you omit this
you will be prompted to enter a hidden password.
-h If the target system is Vista or higher, has the process
run with the account's elevated token, if available.

2) Создать задачу в task scheduler и выполнить скрипт, лучший вариант
3) Пароль можно указать, но пользователю явно придеться нажать Да/Yes ,т.к. UAC не даст запустить, только отключение. Сохраняем скрипт и выполняем его, а из него будет уже вызваться основной:

Код: Выделить весь код
$pass = ConvertTo-SecureString 'P@$$w0rd1' -AsPlainText -Force 
$creds = New-Object System.Management.Automation.PSCredential ("domain\user", $pass)
$ScriptName = 'C:\Scripts\test.ps1'
$arg = "Start-Process powershell -Verb RunAs -ArgumentList '-ExecutionPolicy ByPass -File $ScriptName'"
Start-Process powershell -Credential $creds  -ArgumentList $arg
Это сообщение посчитали полезным следующие участники:

Отправлено: 15:56, 11-04-2016 | #6