Batch 2 powershell - Remote actions: reinstall and run


hi guys, i’m @ moment on way port many batch scripts power shell , encounter problems , questions.

 

1)    what best way locale administration privileges?

(i wan’t store credentials within script , not promt them)

 

2)    whats best way remotely execute commands?

i have uninstall, install software, reboot , execute commands.

 

for rebooting use:

$user = "domain\admin"

$pass = convertto-securestring ‘password’ -asplaintext -force

$cred = new-object -typename system.management.automation.pscredential $user, $pass

$ip = "10.10.10.161"

(get-wmiobject -class win32_operatingsystem -computername $ip -credential $cred).invokemethod("win32shutdown",6)

 

local uninstall:

$app = get-wmiobject -class win32_product | where-object { $_.name -match "softwarename" }

$app.uninstall()

 

local install:

cmd /c msiexec /package newsoftware.msi /quiet

 

 

changing registry entries not found till now. (didn’ now)

how best use these commands (or better?) remotely in best way?


hi eric,

for rebooting why dont use restart-computer cmdlet?

  restart-computer -computername $machine -credential $cred  

other remote command may use invoke-command cmdlet:

  invoke-command -computername $machine -credential $cred -scriptblock {<your commands>}  



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Edit Group Policy

Hyper-V VM not reaching OS 'Logon' screen

DNS question...