Author Posts

July 30, 2018 at 2:03 pm

I am using an invoke command to pull out the WSUS service from list of server. However, for 1 server I need to use a different credential. Wondering how I can get this accomplished.

sample as below:-

# Input file
import-module ($Env:SMS_ADMIN_UI_PATH.Substring(0,$Env:SMS_ADMIN_UI_PATH.Length-5) + '\ConfigurationManager.psd1')
Import-Module ActiveDirectory

Set-Location ABC:


foreach ($C in $computername)
$userdata = (Invoke-Command -ComputerName $c -ScriptBlock {Get-service WsusService| select displayname, Status| sort-Object Status})

July 30, 2018 at 4:34 pm

You would use the -Credential parameter of Invoke-Command.

July 30, 2018 at 4:44 pm

Since you have a foreach loop that iterates through the list of computers, something like this perhaps:

#creds for separate server
$creds = Get-Credential -Credential "domain\username"

foreach ($C in $computername)
    if ($c -match "name of server with own credentials")
       Invoke-Command -Credential $creds

July 31, 2018 at 8:17 am

Thanks Richard, but will this prompt for the password. I need to set this as Schedule task. I know, I am asking very basic thing here, but trying to get the hold of it.