Senior Systems Engineer
Senior Systems Engineer

Reputation: 1153

Unable to Start-Process using another AD account?

The below script is unable to start the application as Separate AD user account.

I wanted the run the below application in C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools as separate AD account DOMAIN\Admin.User1 as oppose to just double clicking it and run as DOMAIN\FirstName.LastName normal user.

enter image description here

This is the script i have created but failed to open:

$ApplicationList = @(
    '%windir%\system32\dsac.exe'
    '%windir%\system32\compmgmt.msc /s'
    '%windir%\system32\mmc.exe %windir%\system32\Cluadmin.msc'
    '%SystemRoot%\system32\mmc.exe %SystemRoot%\system32\dnsmgmt.msc'
)
$credential = Get-Credential -Message "Use your Admin Account" -Title "Run as other account script"
ForEach ( $Application in $ApplicationList ) {
    Start-Process -FilePath $Application -Credential $credential
}

I also have checked the DOMAIN\Admin.User1 Account is not even locked, however, the issue is like:

Start-Process:
Line |
  11 |      Start-Process -FilePath $Application -Credential $credential
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | This command cannot be run due to the error: The referenced account is currently locked out and may not be logged on to.

The below line works, but not sure how to integrate it to the above main script as above:

Start-Process "$($env:windir)\system32\compmgmt.msc" -ArgumentList "/s"

Upvotes: 0

Views: 253

Answers (1)

Shaqil Ismail
Shaqil Ismail

Reputation: 1969

Your command below,

Start-Process "$($env:windir)\system32\compmgmt.msc" -ArgumentList "/s"

worked with the -ArgumentList parameter you have said, so replace this in the $ApplicationList to run with Start-Process, for example for compmgmt.exe only You would change the $applicationList

$ApplicationList = @(
    '"$($env:windir)\system32\compmgmt.msc" -ArgumentList "/s"'
)
$credential = Get-Credential -Message "Use your Admin Account" -Title "Run as other account script"
ForEach ( $Application in $ApplicationList ) {
    Start-Process $Application
}

Upvotes: 1

Related Questions