PSCredential for Nt Authority accounts

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.

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

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/new-service?view=powershell-5.1

-Credential 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,

What about DSC properties that only accept PSCredential objects?

xScheduledTask -module xComputerManagement