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

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

android - ConstraintLayout: Realign baseline constraint in case if dependent view visibility was set to GONE -

c# - Populating Gridview inside Listview ItemTemplate On Web User Control from Code Behind -