powershell - Run .bat file with Administrative rights -


my powershell script runs .bat file install .msu file. need run .bat file administrator rights.

the .bat file is:

wusa c:\temp\win8.1andw2k12r2-kb3191564-x64.msu /quiet /norestart 

i have domain controller , lot of clients. powershell ps session interactively connect every client. need use bat file domain admin credentials, how can this?

you use invoke-command

you save servers in list in text file , use get-content command save array in variable:

$clients = get-content c:\exampleclientlist.txt 

then use variable computername parameter of invoke-command. in scriptblock parameter run command, since can run executables in powershell there isn't need bat file. last credential parameter allow run local administrator.

invoke-command -computername $clients -scriptblock {wusa c:\temp\win8.1andw2k12r2-kb3191564-x64.msu /quiet /norestart} -credential (get-credential) 

Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -