Delete an instance of an existing Windows Management Instrumentation (WMI) class. The preferred cmdlet is now Remove-CimInstance.

      Remove-WmiObject [-Class] string [-Authentication AuthenticationLevel]
         [-Authority string] [-ComputerName string[]] [-Credential PSCredential]
            [-EnableAllPrivileges] [-Impersonation ImpersonationLevel]
               [-Locale string] [-Namespace string] [-AsJob] [-ThrottleLimit int]
                  [-Confirm] [-WhatIf] [CommonParameters]
      Remove-WmiObject [-Authentication AuthenticationLevel]
         [-Authority string] [-ComputerName string[]] [-Credential PSCredential]
            [-EnableAllPrivileges] [-Impersonation ImpersonationLevel]
               [-Locale string] [-Namespace string] [-AsJob] [-ThrottleLimit int]
                  [-Confirm] [-WhatIf] [CommonParameters]
      Remove-WmiObject -InputObject ManagementObject [-AsJob] [-ThrottleLimit int]
         [-Confirm] [-WhatIf] [CommonParameters]
      Remove-WmiObject -Path string [-Authentication AuthenticationLevel]
         [-Authority string] [-ComputerName string[]] [-Credential PSCredential]
            [-EnableAllPrivileges] [-Impersonation ImpersonationLevel]
               [-Locale string] [-Namespace string] [-AsJob] [-ThrottleLimit int]
                  [-Confirm] [-WhatIf] [CommonParameters]
       Run the command as a background job.
       Results from remote computers are automatically returned to the local computer.
       To get the job results, use -Receive-Job
       Note: To use this parameter with remote computers, the local and remote
       computers must be configured for remoting. Additionally, you must start
       PowerShell in Elevated mode/"Run as administrator"

   -Authentication AuthenticationLevel
       The authentication level to be used with the WMI connection.
       Valid values are listed below.

   -Authority string
       The authority to use to authenticate a remote WMI connection:
       NTLM     = ntlmdomain:DomainName
       Kerberos = kerberos:DomainName\ServerName

   -Class string
       The name of a WMI class to be deleted.

   -ComputerName string[]
       The computer(s) to run against.
       A NETBIOS name, an IP address, full domain name or local (.)
       WMI information is retrieved via the WMI Service (CIMOM)
       on the specified computers. This does not rely on PowerShell remoting.

   -Credential PSCredential
       Use the specified credential to authenticate the user. Type a user name  
       or submit a credential object (created with Get-Credential)
       If you supply a user name, you will be prompted for a password.

       Enable all the privileges of the current user before the command makes the WMI call.

   -Impersonation ImpersonationLevel
       The impersonation level to use: Default | Anonymous | Identify | Impersonate | Delegate
       0: Default (read the registry for the default, which is usually set to "3".)
       1: Anonymous (Hide the credentials of the caller.)
       2: Identify (Allow objects to query the credentials of the caller.)
       3: Impersonate (Allow objects to use the credentials of the caller.)
       4: Delegate (Allow objects to permit other objects to use the credentials of the caller.)

   -InputObject ManagementObject
       A ManagementObject object to use as input.
       When this parameter is used, all other parameters are ignored.

   -Locale string
       The preferred locale for WMI objects.
       Specify as an array in MS_LCID format in the preferred order.

   -Namespace string
       The WMI repository namespace.
       When used with the -Class parameter, this parameter specifies the
       namespace where the referenced WMI class is located.

   -Path string
The WMI object path of a WMI class, or the WMI object path of an instance of a WMI class to be deleted. -ThrottleLimit int Allow the user to specify a throttling value for the number of WMI operations that can be executed simultaneously. (Used together with -AsJob.) -Confirm Prompt for confirmation before executing the command. -WhatIf Describe what would happen if you executed the command without actually executing it.

Standard Aliases for Remove-WmiObject: rwmi

For WMI to work against a remote machine you may need to first configure its local Windows firewall to allow the remote access.

Authentication Levels:

Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy | Unchanged

0: Default
1: None (No authentication in performed.)
2: Connect (Authentication is performed only when the client establishes a relationship with the application.)
3: Call (Authentication is performed only at the beginning of each call when the application receives the request.)
4: Packet (Authentication is performed on all the data that is received from the client.)
5: PacketIntegrity (All the data that is transferred between the client and the application is authenticated and verified.)
6: PacketPrivacy (The properties of the other authentication levels are used, and all the data is encrypted.)
-1: Unchanged


Close all the instances of Notepad.exe:

PS C:\> notepad
PS C:\> $np = Get-WMIObject -query "select * from win32_process where name='notepad.exe'"
PS C:\> $np | Remove-WmiObject

Delete the C:\Test directory:

PS C:\> $testfolder = Get-WMIObject -query "Select * From Win32_Directory Where Name ='C:\\Test'"
PS C:\> $testfolder | Remove-WmiObject

“There is no abstract art. You must always start with something. Afterward you can remove all traces of reality” ~ Pablo Picasso

Related PowerShell Cmdlets

Get-WmiObject - Get WMI class information.

Copyright © 1999-2024
Some rights reserved