If you're using PowerShell 7 the Set-Service cmdlet can manage this.
If, on the other hand, you're using PowerShell 5, you can use WMI to handle it. Have a look at this: powershell-script-to-change-service-account
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi there,
I would like to create a script in PowerShell that facilitates people to change the Log On As information for a specific Service with local admin passwords.
There is an app, for Dell computers, called SupportAssist. This app only works when logged in with a local administrator session but on the Dell community I have found out that with a little trick, you can get it working also when logged in as a normal user (with no admin rights): https://www.dell.com/community/SupportAssist-for-PCs/SupportAssist-run-as-admin/td-p/7187490
So I would like to automate most of the steps leaving the users only the burden of having to type the local admin password. When googling about this, I found this page https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/set-service?view=powershell-7.1 and I thought that the following lines would be enough:
$credential = Get-Credential
Set-Service -Name "Dell SupportAssist" -Credential $credential
The problem is that the Get-Credential cmdlet wants me to type domain credentials but I need to set the Log on as config of the Service as local administrator instead:
Maybe there is another cmdlet to do this or do I have to add some more lines to specify that I am referring to the localhost? Any help would be much appreciated.
Thanks in advance
If you're using PowerShell 7 the Set-Service cmdlet can manage this.
If, on the other hand, you're using PowerShell 5, you can use WMI to handle it. Have a look at this: powershell-script-to-change-service-account