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))
or
$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.