Running PowerShell version 5.0 on Windows 10 Build 10240. I need to obtain a PSCredential
instance that contains the LocalSystem context. How can I achieve this?
https://msdn.microsoft.com/en-us/library/windows/desktop/ms684190(v=vs.85).aspx
Running PowerShell version 5.0 on Windows 10 Build 10240. I need to obtain a PSCredential
instance that contains the LocalSystem context. How can I achieve this?
https://msdn.microsoft.com/en-us/library/windows/desktop/ms684190(v=vs.85).aspx
From the documentation you linked to:
This account does not have a password. If you specify the LocalSystem account in a call to the CreateService or ChangeServiceConfig function, any password information you provide is ignored.
So, just supply "any password information" in the pscredential
constructor:
$Username = "NT AUTHORITY\SYSTEM"
$Password = "whatever you feel like" | ConvertTo-SecureString -AsPlainText -Force
$LocalSystemCreds = New-Object -TypeName pscredential -ArgumentList $Username,$Password