How to make credential object in non-admin powershell?
Run from an admin powershell, this prompts for password as expected > $Cred = Get-Credential
Run from a non-admin powershell, i get error:
> $Cred = Get-Credential
cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Credential
Get-Credential : Cannot process command because of one or more missing mandatory parameters: Credential.
At line:1 char:9
+ $Cred = Get-Credential
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-Credential], ParameterBindingException
+ FullyQualifiedErrorId : MissingMandatoryParameter,Microsoft.PowerShell.Commands.GetCredentialCommand
BOOM is the local admin. Boombox is the machine name. I’ve tried all these forms. All work in admin PS. None work in non-admin PS. Something on your machine is different than mine. I wonder what it is
My goal is to make a bat or PS1 script on a non-admin account, which can execute pnputil twice, and never ask me for credentials, or at most just once.
The best I can do is the following bat script which requests password twice:
Others have given me some comparatively long and complicated Scripts involving scheduled tasks. Seems to me that this should be doable with a simple one-liner like my bat above.
here’s a pure Powershell approach period if I can minimize or eliminate password requests in a non-admin account I’m good
I’m in a domain environment and used domain accounts.
You create a scheduled task starting your script only on demand containing all necessary commands but without any credential stuff in it. Then you configure this task to run with highest privileges with the local SYSTEM account and configure it to be allowed to be run by others … even without admin rights.