Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5/31/2024 PM Publish #11154

Merged
merged 3 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 34 additions & 35 deletions reference/5.1/CimCmdlets/Get-CimAssociatedInstance.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
external help file: Microsoft.Management.Infrastructure.CimCmdlets.dll-Help.xml
Locale: en-US
Module Name: CimCmdlets
ms.date: 12/09/2022
online version: https://learn.microsoft.com/powershell/module/cimcmdlets/get-cimassociatedinstance?view=powershell-5.1&WT.mc_id=ps-gethelp
ms.date: 05/31/2024
online version: https://learn.microsoft.com/powershell/module/cimcmdlets/get-cimassociatedinstance?view=powershell-7.4&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Get-CimAssociatedInstance
---
Expand Down Expand Up @@ -39,7 +39,7 @@ instance, called the source instance, by an association.
In an association, each CIM instance has a named role and the same CIM instance can participate in
an association in different roles.

If the InputObject parameter is not specified, the cmdlet works in one of the following ways:
If the **InputObject** parameter isn't 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
Expand Down Expand Up @@ -69,43 +69,38 @@ $disk = Get-CimInstance -ClassName Win32_LogicalDisk -KeyOnly
Get-CimAssociatedInstance -InputObject $disk[1] -ResultClass Win32_DiskPartition
```

This set of commands retrieves all the instances of the **Win32_LogicalDisk** class and stores
them in a variable named `$disk`. The first logical disk instance in the variable is then used as the
This set of commands retrieves all the instances of the **Win32_LogicalDisk** class and stores them
in a variable named `$disk`. The first logical disk instance in the variable is then used as the
input object for the `Get-CimAssociatedInstance` cmdlet to get all the associated instances that are
associated through the specified association class **Win32_DiskPartition**.

### Example 3: Get all the associated instances through qualifier of a specific class

This set of commands retrieves the services that depend on the **Winmgmt** service and stores them
in a variable named `$s`. `Get-CimAssociatedInstance` gets the associated instances of the retrieved
association class.

```powershell
$s = Get-CimInstance -Query "Select * from Win32_Service where name like 'Winmgmt'"
Get-CimClass -ClassName *Service* -Qualifier "Association"
$c.CimClasName
Get-CimAssociatedInstance -InputObject $s -Association Win32_DependentService
```

```Output
Win32_LoadOrderGroupServiceDependencies
Win32_DependentService
Win32_SystemServices
Win32_LoadOrderGroupServiceMembers
Win32_ServiceSpecificationService
```

```powershell
Get-CimAssociatedInstance -InputObject $s -Association Win32_DependentService
ProcessId Name StartMode State Status ExitCode
--------- ---- --------- ----- ------ --------
1716 RpcSs Auto Running OK 0
9964 CcmExec Auto Running OK 0
0 HgClientService Manual Stopped OK 1077
0 smstsmgr Manual Stopped OK 1077
3396 vmms Auto Running OK 0
```

This set of commands retrieves the services that depend on WMI service and stores them in a variable
named `$s`. The association class name for the **Win32_DependentService** is retrieved using the
`Get-CimClass` cmdlet by specifying **Association** as the qualifier and is then passed with $s to
the `Get-CimAssociatedInstance` cmdlet to get all the associated instances of the retrieved
association class.

## PARAMETERS

### -Association

Specifies the name of the association class. If you do not specify this parameter, the cmdlet
returns all existing association objects of any type.
Specifies the name of the association class. If you don't specify this parameter, the cmdlet returns
all existing association objects of any type.

For example, if class A is associated with class B through two associations, AB1 and AB2, then this
parameter can be used to specify the type of association, either AB1 or AB2.
Expand All @@ -116,7 +111,7 @@ Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Expand Down Expand Up @@ -148,7 +143,7 @@ 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
If you don't 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
Expand Down Expand Up @@ -180,15 +175,15 @@ Parameter Sets: (All)
Aliases: CimInstance

Required: True
Position: 1
Position: 0
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```

### -KeyOnly

Returns objects with only key properties populated. This reduces the amount of data that is
Returns objects with only key properties populated. This reduces the amount of data that's
transferred over the network.

```yaml
Expand All @@ -208,8 +203,8 @@ Accept wildcard characters: False
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 PowerShell gets a
> list of namespaces from the local WMI server to provide the list of namespaces.
> You can use tab completion to browse the list of namespaces, because PowerShell gets a list of
> namespaces from the local WMI server to provide the list of namespaces.

```yaml
Type: System.String
Expand All @@ -231,7 +226,7 @@ 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
parameter aren't recoverable, because the operation on the server times out before the client can
reconnect.

```yaml
Expand All @@ -256,13 +251,13 @@ 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 URI
By default, if you don't specify this parameter, the DMTF standard resource URI
`http://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 the **ComputerName** 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 get an error, because the DCOM protocol does not support the
created using DCOM protocol, you get an error, because the DCOM protocol doesn't support the
**ResourceURI** parameter.

If both the **ResourceUri** parameter and the **Filter** parameter are specified, the **Filter**
Expand All @@ -283,13 +278,13 @@ Accept wildcard characters: False
### -ResultClassName

Specifies the class name of the associated instances. A CIM instance can be associated with one or
more CIM instances. All associated CIM instances are returned if you do not specify the result class
more CIM instances. All associated CIM instances are returned if you don't specify the result class
name.

By default, the value of this parameter is null, and all associated CIM instances are returned.

You can filter the association results to match a specific class name. Filtering happens on the
server. If this parameter is not specified, `Get-CIMAssociatedInstance` returns all existing
server. If this parameter isn't specified, `Get-CIMAssociatedInstance` returns all existing
associations. For example, if class A is associated with classes B, C and D, then this parameter can
be used to restrict the output to a specific type (B, C or D).

Expand Down Expand Up @@ -326,6 +321,10 @@ This cmdlet returns a CIM instance object.

## NOTES

Windows PowerShell includes the following aliases for `Get-CimAssociatedInstance`:

- `gcai`

## RELATED LINKS

[Get-CimClass](get-cimclass.md)
Expand Down
71 changes: 56 additions & 15 deletions reference/5.1/Microsoft.PowerShell.Utility/New-Alias.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Utility
ms.date: 12/12/2022
ms.date: 05/31/2024
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/new-alias?view=powershell-5.1&WT.mc_id=ps-gethelp
schema: 2.0.0
title: New-Alias
Expand All @@ -16,38 +16,75 @@ Creates a new alias.
## SYNTAX

```
New-Alias [-Name] <String> [-Value] <String> [-Description <String>] [-Option <ScopedItemOptions>] [-PassThru]
[-Scope <String>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]
New-Alias [-Name] <String> [-Value] <String> [-Description <String>] [-Option <ScopedItemOptions>]
[-PassThru] [-Scope <String>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION

The `New-Alias` cmdlet creates a new alias in the current Windows PowerShell session. Aliases
created by using `New-Alias` are not saved after you exit the session or close Windows PowerShell.
The `New-Alias` cmdlet creates a new alias in the current PowerShell session. Aliases
created by using `New-Alias` are not saved after you exit the session or close PowerShell.
You can use the `Export-Alias` cmdlet to save your alias information to a file. You can later use
`Import-Alias` to retrieve that saved alias information.

## EXAMPLES

### Example 1: Create an alias for a cmdlet

```
```powershell
New-Alias -Name "List" Get-ChildItem
```

This command creates an alias named List to represent the Get-ChildItem cmdlet.

### Example 2: Create a read-only alias for a cmdlet

```
This command creates an alias named `C` to represent the `Get-ChildItem` cmdlet. It creates a
description of "quick gci alias" for the alias and makes it read-only.

```powershell
New-Alias -Name "C" -Value Get-ChildItem -Description "quick gci alias" -Option ReadOnly
Get-Alias -Name "C" | Format-List *
```

This command creates an alias named `C` to represent the `Get-ChildItem` cmdlet. It creates a
description, quick wmi alias, for the alias and makes it read-only. The last line of the command
uses `Get-Alias` to get the new alias and pipes it to Format-List to display all of the information
about it.
```Output
HelpUri : https://go.microsoft.com/fwlink/?LinkID=2096492
ResolvedCommandName : Get-ChildItem
DisplayName : C -> Get-ChildItem
ReferencedCommand : Get-ChildItem
ResolvedCommand : Get-ChildItem
Definition : Get-ChildItem
Options : ReadOnly
Description : quick gci alias
OutputType : {System.IO.FileInfo, System.IO.DirectoryInfo}
Name : C
CommandType : Alias
Source :
Version :
Visibility : Public
ModuleName :
Module :
RemotingCapability : PowerShell
Parameters : {[Path, System.Management.Automation.ParameterMetadata], [LiteralPath,
System.Management.Automation.ParameterMetadata], [Filter,
System.Management.Automation.ParameterMetadata], [Include,
System.Management.Automation.ParameterMetadata]…}
```

The `Get-Alias` command piped to `Format-List` shows all of the information about the new alias.

### Example 3: Create an alias for a command with parameters

```powershell
function Set-ParentDirectory {Set-Location -Path ..}
New-Alias -Name .. -Value Set-ParentDirectory
```

The first command creates the function `Set-ParentDirectory`, which uses `Set-Location` to set the
working location to the parent directory. The second command uses `New-Alias` to create an alias
of `..` to call the `Set-ParentDirectory` function. Since the Value parameter requires a cmdlet,
function, or executable value, you must create a custom function to create an alias that uses
parameters. Running the alias `..` changes the current location to the parent directory.

## PARAMETERS

Expand Down Expand Up @@ -162,7 +199,8 @@ Specifies the scope of the new alias. The acceptable values for this parameter a
- A number relative to the current scope (0 through the number of scopes, where `0` is the current
scope and `1` is its parent).

`Local` is the default. For more information, see [about_Scopes](../Microsoft.PowerShell.Core/About/about_Scopes.md).
`Local` is the default. For more information, see
[about_Scopes](../Microsoft.PowerShell.Core/About/about_Scopes.md).

```yaml
Type: System.String
Expand Down Expand Up @@ -226,7 +264,10 @@ Accept wildcard characters: False

### CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
-WarningAction, and -WarningVariable. For more information, see
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

Expand All @@ -251,8 +292,8 @@ Windows PowerShell includes the following aliases for `New-Alias`:

- `nal`

- To create a new alias, use `Set-Alias` or `New-Alias`. To change an alias, use `Set-Alias`. To delete
an alias, use `Remove-Item`.
- To create a new alias, use `Set-Alias` or `New-Alias`. To change an alias, use `Set-Alias`. To
delete an alias, use `Remove-Item`.

## RELATED LINKS

Expand Down
Loading
Loading