How to Impersonate in Powershell

PowerShell has various properties and parameters set for each object it contains. It even has a parameter for the Get-WmiObject where you can impersonate a user. In this tutorial, you will get acquainted with the ImpersonationLevel parameter in PowerShell.

Setup

If you have not already done so, click open Windows PowerShell. Remember, in order to run scripts and various commands, you must run PowerShell as the administrator.

Concept one

There are five level values that one may choose from for impersonation. The command is quite simple, you need the system to get WmiObject, name space and have the appropriate settings applied. An example of this command is as follows:

Example

Get-WmiObject "Namespace root\cimv2 "Class Win32_Process "Impersonation 3 "ComputerName Computer_B
    

Copy and Try it

You must be an administrator in the system you are using to do the impersonation, otherwise, the command will only print out an error.

Concept two

As previously stated there are five different levels of impersonation. The levels are listed in the table below by level number.

Name

Description

Impersonation Level
Parameter Value

Default

Uses the default value of the remote host.

0

Anonymous

Hides your credentials from the WMI Provider

1

Identify

Enables WMI objects to query for your credentials. Default for WMI pre-version 1.5.

2

Impersonate

Enables WMI objects to use your credentials when running, thereby impersonating you. This level is the default for WMI version 1.5 or the later.

3

Delegate

Lets WMI objects impersonate you and additionally use your credentials to access other objects on other systems.

4

Remarks last but not least!

There are various applications to today's lesson, keep in mind, in order to impersonate, you must have administrative privileges. So you still need permission. Thank you for being a valued reader. Join us next time for additional Windows PowerShell tutorials! Till then..