August 17th, 2012

PowerTip: Working with Alternate Credentials with WMI

Doctor Scripto
Scripter

Summary: Learn four  ways to supply alternate credentials with WMI and Windows PowerShell.

Hey, Scripting Guy! Question How can I supply alternate credentials for a remote WMI call when I am using the Get-WmiObject cmdlet?

Hey, Scripting Guy! Answer

a. Use the credential parameter as shown here.

Get-WmiObject Win32_BIOS -ComputerName Server01 -Credential (get-credential ` Domain01@User01)

b. Use the credential parameter as shown here.

$c = Get-Credential

Get-WmiObject Win32_DiskDrive -ComputerName Server01 -Credential $c

c. Create a CIM session to the remote system by using the New-CimSession.

d. Create a PS session to the remote system by using New-PSSession.

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.