NAME
Remove-CimInstance
SYNOPSIS
Removes a CIM instance from a computer.SYNTAX
Remove-CimInstance [-InputObject]
[-ComputerName ] [-OperationTimeoutSec ] [-ResourceUri
] [-Confirm] [-WhatIf] [ ] Remove-CimInstance [-InputObject]
[-OperationTimeoutSec ] [-ResourceUri ] -CimSession
[-Confirm] [-WhatIf] [ ] Remove-CimInstance [-Query]
[[-Namespace] ] [-OperationTimeoutSec ] [-QueryDialect
] -CimSession [-Confirm] [-WhatIf] [ ] Remove-CimInstance [-Query]
[[-Namespace] ] [-ComputerName ] [-OperationTimeoutSec
] [-QueryDialect ] [-Confirm] [-WhatIf] [ ] DESCRIPTION
The Remove-CimInstance cmdlet removes a Common Information Model (CIM) instance from a CIM server.
You can specify the CIM instance to remove by using either a CIM instance object retrieved by the Get-CimInstance
cmdlet, or by specifying a query. If the InputObject parameter is not specified, the cmdlet works in one of the following ways:--If neither the ComputerName parameter nor the CimSession parameter is specified, then this cmdlet works on local
Windows Management Instrumentation (WMI) using a Component Object Model (COM) session.--If either the ComputerName parameter or the CimSession parameter is specified, then this cmdlet works against
the CIM server specified by either the ComputerName parameter or the CimSession parameter.
PARAMETERS
-CimSession
Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session object, suchas the output of a New-CimSession or Get-CimSession cmdlet. The default is the current session on the local
computer. Required? true Position? named Default value none Accept pipeline input? True (ByValue) Accept wildcard characters? false-ComputerName [
Specifies the name of the computer on which you want to run the CIM operation. You can specify a fully qualified domain name (FQDN) or a NetBIOS name. If you specify this parameter, the cmdlet creates a temporary session to the specified computer using the WsMan protocol. If you do not specify this parameter, the cmdlet performs the operation on the local computer using Component Object Model (COM). If multiple operations are being performed on the same computer, connecting using a CIM session gives better performance. Required? false Position? named Default value none Accept pipeline input? false Accept wildcard characters? false] -InputObject
Specifies a CIM instance object to be removed from the CIM server. Note: The input object passed to the cmdlet is not changed, only the instance in the CIM server is removed. Required? true Position? 1 Default value none Accept pipeline input? True (ByValue) Accept wildcard characters? false-Namespace [
Specifies the namespace for the CIM operation. The default namespace is root/cimv2. Note: You can use tab completion to browse the list of namespaces, because Windows PowerShell gets a list of namespaces from the local WMI server to provide the list of namespaces. Required? false Position? 2 Default value none] Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false-OperationTimeoutSec [
Specifies the amount of time that the cmdlet waits for a response from the computer. By default, the value of this parameter is 0, which means that the cmdlet uses the default timeout value for the server. If the OperationTimeoutSec parameter is set to a value less than the robust connection retry timeout of 3 minutes, network failures that last more than the value of the OperationTimeoutSec parameter are not recoverable, because the operation on the server times out before the client can reconnect. Required? false Position? named Default value none Accept pipeline input? false Accept wildcard characters? false] -Query
Specifies a query to run on the CIM server. You can specify the query dialect using the QueryDialect parameter. If the value specified contains double quotes ("), single quotes (`), or a backslash (\), you must escape those characters by prefixing them with the backslash (\) character. If the value specified uses the WQL LIKE operator, then you must escape the following characters by enclosing them in square brackets ([]): percent(%), underscore (_), or opening square bracket ([).
Required? true Position? 1 Default value noneAccept pipeline input? True (ByPropertyName)
Accept wildcard characters? false-QueryDialect [
Specifies the query language used for the Query parameter. The acceptable values for this parameter are:] -- WQL
-- CQL
The default value is WQL. Required? false Position? named Default value noneAccept pipeline input? True (ByPropertyName)
Accept wildcard characters? false-ResourceUri [
Specifies the resource uniform resource identifier (URI) of the resource class or instance. The URI is used to identify a specific type of resource, such as disks or processes, on a computer. A URI consists of a prefix and a path to a resource. For example: http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_LogicalDisk] http://intel.com/wbem/wscim/1/amt-schema/1/AMT_GeneralSettings
By default, if you do not specify this parameter, the DMTF standard resource URIhttp://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/ is used and the class name is appended to it.
ResourceURI can only be used with CIM sessions created using the WSMan protocol, or when specifying theComputerName parameter, which creates a CIM session using WSMan. If you specify this parameter without
specifying the ComputerName parameter, or if you specify a CIM session created using DCOM protocol, you will
get an error, because the DCOM protocol does not support the ResourceUri parameter. If both the ResourceUri parameter and the Filter parameter are specified, the Filter parameter is ignored. Required? false Position? named Default value noneAccept pipeline input? True (ByPropertyName)
Accept wildcard characters? false-Confirm [
Prompts you for confirmation before running the cmdlet.Prompts you for confirmation before running the cmdlet. Required? false Position? named Default value false Accept pipeline input? false Accept wildcard characters? false] -WhatIf [
Shows what would happen if the cmdlet runs. The cmdlet is not run.Shows what would happen if the cmdlet runs. The cmdlet is not run. Required? false Position? named Default value false Accept pipeline input? false Accept wildcard characters? false] This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable. For more information, see about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216). INPUTS
None This cmdlet accepts no input objects.OUTPUTS
None This cmdlet produces no outputs.Example 1: Remove the CIM instance
PS C:\>Remove-CimInstance -Query 'Select * from Win32_Environment where name LIKE "testvar%"?
This command removes the CIM instances that start with the character string testvar from the class named Win32_Environment using the Query parameter.Example 2: Remove the CIM instance using a CIM instance object
PS C:\>calc.exe
PS C:\> $var = Get-CimInstance -Query 'Select * from Win32_Process where name LIKE "calc%"'
PS C:\> Remove-CimInstance -InputObject $var
This set of commands retrieves the CIM instance objects filtered by the Query parameter and stores them invariable named $var using the Get-CimInstance cmdlet. The contents of the variable are then passed to the
Remove-CimInstance cmdlet, which removes the CIM instances.
RELATED LINKS
Online Version:Get-CimInstance
New-CimInstance
Set-CimInstance