@DanC
Hi Dan,
Our processes will run as local system so that is why you aren't (or it isn't) bothered by UAC. There isn't a special switch in the command that is allowing you to bypass it.
Out of curiosity, why the need to silently stop our services? Trying to think of a use case for this situation so if you could advise that'd be appreciated (and I can do some digging on some options you may have).
Thanks,
Chris
@Chris Hollis
When it comes to a Linux server, one can employ the sudo command to gracefully stop the Commvault services before initiating a reboot(once OS patching complete).
Regarding Windows servers, my objective is to automate the procedure of gracefully stopping the Commvault services on multiple servers, which could be as many as a hundred, and subsequently rebooting each server after the patching process.
Start-Process -FilePath "cmd.exe" -ArgumentList "/C cd /d C:\Program Files\Commvault\ContentStore\Base\ && GxAdmin.exe -console -stopsvcgrp All" -PassThru -NoNewWindow
After testing the above PS command on a single Windows client, the server's UAC feature was enabled, resulting in a prompt to authorize the execution of the command. Disabling UAC allowed the command to proceed without requiring any manual intervention.
The question at hand is how to automate stop Commvault services on a Windows client via command line without disabling UAC.
thanks
@Chris Hollis
i figured it out and this works fine
$computers = get-content “C:\XXX\XXX.txt”
$scriptBlock = {
Param (
string]$Command
)
Start-Process -FilePath "cmd.exe" -ArgumentList "/C $Command" -NoNewWindow -Wait
}
Invoke-Command -ComputerName $computers -ScriptBlock $scriptBlock -ArgumentList 'cd /d "C:\Program Files\Commvault\ContentStore\Base\" && GxAdmin.exe -console -stopsvcgrp All'