MicrosoftDocs / windows-powershell-docs

This repo is used to contribute to Windows 10, Windows Server 2016, and MDOP PowerShell module documentation.
Creative Commons Attribution 4.0 International
444 stars 591 forks source link

Add-ClusterResourceDependency has an incorrect example and unclear parameters #1596

Closed paul-alt-delete closed 4 years ago

paul-alt-delete commented 4 years ago

The current example for Add-ClusterResourceDependency is incorrect:

Add-ClusterResourceDependency -Cluster "FileServer-(cluster1FS12)(Cluster Disk 2)" -Resource "Cluster Disk 4"

The generic -Cluster parameter indicates what cluster to connect to, not the resource to add the new dependency to.

When I checked the parameter descriptions to find the correct usage, I found that some parameters seem mutually exclusive (like -InputObject and -Resource). But this isn't called out, and the command doesn't use parameter sets to enforce that. I tried testing different parameter combinations on a 2012 R2 test cluster, and found three valid combinations. So ideally, the documentation should be updated to show those three usage options:

# Example 1: Corrected version of the current example
Add-ClusterResourceDependency -Resource 'File Server (\\cluster1FS12)' -Provider 'Cluster Disk 4'

# Example 2: Pipe in the main resource, add the dependency using the -Provider parameter
Get-ClusterResource -Name 'File Server (\\cluster1FS12)' | Add-ClusterResourceDependency -Provider 'Cluster Disk 4'

# Example 3: Pipe in the main resource, add the dependency using the -Resource parameter
Get-ClusterResource -Name 'File Server (\\cluster1FS12)' | Add-ClusterResourceDependency -Resource 'Cluster Disk 4'

Example 2 and 3 show how the -Resource parameter can mean different things depending on how the command is run. Based on context, -Resource can mean opposite things, either

I found that surprising and unintuitive, and I'd suspect that others will be confused by it as well. I haven't seen any other PowerShell commands from Microsoft with behavior like that, so it's probably worth explicitly calling out. I'm assuming that the behavior is unintentional, but is kept for backwards compatibility.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

velkovb commented 4 years ago

@paul-alt-delete Hello Paul,

Thank you for trying to make MicrosoftDocs a better place.

This is very confusing indeed. I think it is some kind of a glitch in cmdlet behaviour. I did some tests as well and the logical thing is:

This example could explain it: Get-ClusterResource TestService | Add-ClusterResourceDependency -Resource TestIP2 -Provider TestIP Here the Resource parameter is ignored and only the resource specified in the Provider parameter is added as dependency.

I will fix the example and escalate the other part as bug.