Author Posts

November 17, 2017 at 3:57 pm

I'm trying to capture NT Authority accounts in a variable for the purpose of creating services and scheduled tasks. It won't let me create the object with the password. However if I include a "dummy" password, utilizing it in New-Service or DSC states the password is wrong.

$cred = new-object -typename System.Management.Automation.PSCredential("NT Authority\Network Service",$(ConvertTo-SecureString 'adsf' -AsPlainText -Force))

$cred = get-credential -username 'NT Authority\Network Service' -msg 'whats the password'

So my question is, how can I capture the credentials in a Powershell Object so I can easily reuse it with other powershell commands.

November 17, 2017 at 4:27 pm

Network service doesn't have a password. You should just be able to store nt authority\network service in a standard variable and for say something like register-scheduledtask put the variable in the -user paramaters

$user = "nt authority\network service"
register-scheduledtask -name taskname -user $user

November 17, 2017 at 4:29 pm

Specifies a user account that has permission to perform this action.
Type a user name, such as User01 or Domain01\User01, or enter a PSCredential object,

November 17, 2017 at 8:15 pm

What about DSC properties that only accept PSCredential objects?

xScheduledTask -module xComputerManagement