On Aug 20, 4:19*pm, how to display variable value?
<howtodisplayvariableva...@xxxxxx> wrote:
Quote:
> actually when we use get-wmiobject we pass the remote computer name but
>
> sometimes we need the user credentials to logon to that computer . But how to
>
> pass on the credetilas in get-wmiobject command
I know when I write scripts that involve credentials i usually just do
the following instead of getting prompted every time i do a WMI query
in a loop or something like that.
Example:
$cred = Get-cred domain\user
#when i need to pass it i will just do the following on the gwmi
command as Kryten pointed out.
gwmi -computername pc1 -cred $cred
I find this works well if everything has the same credentials. You
could even do some logic to use one cred and if it doesn't work use
another.
I hope this helps,
PeterCS