Skip to content

Commit 686ee80

Browse files
authored
Feature/12 (#14)
* Add argument completers for ResourceGroupName and WorkspaceName in workspace manager functions * updated parameters * Update API version and remove ArgumentCompleters from ResourceId parameters in workspace manager functions
1 parent 027bf5f commit 686ee80

18 files changed

Lines changed: 96 additions & 36 deletions

src/AzWorkspaceManager.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ $SessionVariables = [ordered]@{
55
baseUri = ''
66
ExpiresOn = ''
77
workspace = ''
8-
apiVersion = '2023-10-01'
8+
apiVersion = '2025-01-01-preview'
99
}
1010

1111
Set-Variable -Name Guid -Value (New-Guid).Guid -Scope Script -Force

src/Private/Get-LogAnalyticsWorkspace.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ function Get-LogAnalyticsWorkspace {
1414
param (
1515
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
1616
[ValidatePattern('^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$', ErrorMessage = "It does not match expected pattern '{1}'")]
17-
[string]$Name,
17+
[Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters.ResourceNameCompleterAttribute(
18+
"Microsoft.OperationalInsights/workspaces",
19+
"ResourceGroupName"
20+
)][string]$Name,
1821

1922
[Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
23+
[Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters.ResourceGroupCompleterAttribute()]
2024
[string]$ResourceGroupName
2125
)
2226

src/Public/Add-AzWorkspaceManager.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ function Add-AzWorkspaceManager {
77
[string]$Name,
88

99
[Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
10+
[Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters.ResourceGroupCompleterAttribute()]
1011
[string]$ResourceGroupName,
1112

1213
[Parameter(Mandatory = $false, ValueFromPipeline = $true)]

src/Public/Add-AzWorkspaceManagerAssignment.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ function Add-AzWorkspaceManagerAssignment {
44
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
55
[ValidatePattern('^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$', ErrorMessage="It does not match expected pattern '{1}'")]
66
[ValidateNotNullOrEmpty()]
7-
[string]$WorkspaceName,
7+
[Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters.ResourceNameCompleterAttribute(
8+
"Microsoft.OperationalInsights/workspaces",
9+
"ResourceGroupName"
10+
)][string]$WorkspaceName,
811

912
[Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
10-
[ValidateNotNullOrEmpty()]
13+
[ValidateNotNullOrEmpty()][Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters.ResourceGroupCompleterAttribute()]
1114
[string]$ResourceGroupName,
1215

1316
[Parameter(Mandatory = $true, ValueFromPipeline = $false)]

src/Public/Add-AzWorkspaceManagerAssignmentJob.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ function Add-AzWorkspaceManagerAssignmentJob {
44
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
55
[ValidateNotNullOrEmpty()]
66
[ValidatePattern('^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$', ErrorMessage="It does not match expected pattern '{1}'")]
7-
[string]$WorkspaceName, # //TODO: Add validation for workspace name
7+
[Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters.ResourceNameCompleterAttribute(
8+
"Microsoft.OperationalInsights/workspaces",
9+
"ResourceGroupName"
10+
)][string]$WorkspaceName,
811

912
[Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
1013
[ValidateNotNullOrEmpty()]
14+
[Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters.ResourceGroupCompleterAttribute()]
1115
[string]$ResourceGroupName,
1216

1317
[Parameter(Mandatory = $false, ValueFromPipeline = $false)]

src/Public/Add-AzWorkspaceManagerGroup.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ function Add-AzWorkspaceManagerGroup {
44
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
55
[ValidateNotNullOrEmpty()]
66
[ValidatePattern('^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$', ErrorMessage="It does not match expected pattern '{1}'")]
7-
[string]$WorkspaceName,
7+
[Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters.ResourceNameCompleterAttribute(
8+
"Microsoft.OperationalInsights/workspaces",
9+
"ResourceGroupName"
10+
)][string]$WorkspaceName,
811

912
[Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
1013
[ValidateNotNullOrEmpty()]
14+
[Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters.ResourceGroupCompleterAttribute()]
1115
[string]$ResourceGroupName,
1216

1317
[Parameter(Mandatory = $true, ValueFromPipeline = $false)]

src/Public/Add-AzWorkspaceManagerMember.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ function Add-AzWorkspaceManagerMember {
44
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
55
[ValidateNotNullOrEmpty()]
66
[ValidatePattern('^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$', ErrorMessage="It does not match expected pattern '{1}'")]
7-
[string]$WorkspaceName,
7+
[Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters.ResourceNameCompleterAttribute(
8+
"Microsoft.OperationalInsights/workspaces",
9+
"ResourceGroupName"
10+
)][string]$WorkspaceName,
811

912
[Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
13+
[Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters.ResourceGroupCompleterAttribute()]
1014
[string]$ResourceGroupName,
1115

1216
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $false)]

src/Public/Get-AzWorkspaceManager.ps1

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ function Get-AzWorkspaceManager {
33
param (
44
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
55
[ValidatePattern('^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$', ErrorMessage = "It does not match expected pattern '{1}'")]
6-
[string]$Name,
6+
[Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters.ResourceNameCompleterAttribute(
7+
"Microsoft.OperationalInsights/workspaces",
8+
"ResourceGroupName"
9+
)][string]$Name,
710

811
[Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
9-
[ValidateNotNullOrEmpty()]
12+
[Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters.ResourceGroupCompleterAttribute()]
1013
[string]$ResourceGroupName
1114
)
1215

@@ -22,7 +25,7 @@ function Get-AzWorkspaceManager {
2225
Get-LogAnalyticsWorkspace -Name $Name
2326
}
2427

25-
try {
28+
# try {
2629
if ($SessionVariables.workspace) {
2730
Write-Verbose "Get Microsoft Sentinel Workspace Manager Configuration for workspace '$Name'"
2831
$uri = "$($SessionVariables.workspace)/providers/Microsoft.SecurityInsights/workspaceManagerConfigurations?api-version=$($SessionVariables.apiVersion)"
@@ -47,10 +50,10 @@ function Get-AzWorkspaceManager {
4750
Write-Message -FunctionName $($MyInvocation.MyCommand.Name) -Message "Workspace Manager is not configured for workspace '$Name'" -Severity 'Information'
4851
$SessionVariables.workspaceManagerConfiguration = $false
4952
}
50-
}
51-
catch {
52-
Write-Message -FunctionName $($MyInvocation.MyCommand.Name) -Message $($_.Exception.Message) -Severity 'Error'
53-
}
53+
# }
54+
# catch {
55+
# Write-Message -FunctionName $($MyInvocation.MyCommand.Name) -Message $($_.Exception.Message) -Severity 'Error'
56+
# }
5457
}
5558
<#
5659
.SYNOPSIS

src/Public/Get-AzWorkspaceManagerAssignment.ps1

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
function Get-AzWorkspaceManagerAssignment {
22
[cmdletbinding()]
33
param (
4-
[Parameter(Mandatory = $false, ValueFromPipeline = $true)]
4+
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
55
[ValidateNotNullOrEmpty()]
66
[ValidatePattern('^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$', ErrorMessage="It does not match expected pattern '{1}'")]
7-
[string]$WorkspaceName,
7+
[Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters.ResourceNameCompleterAttribute(
8+
"Microsoft.OperationalInsights/workspaces",
9+
"ResourceGroupName"
10+
)][string]$WorkspaceName,
811

9-
[Parameter(Mandatory = $false, ValueFromPipeline = $true)]
10-
[ValidateNotNullOrEmpty()]
12+
[Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
13+
[Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters.ResourceGroupCompleterAttribute()]
1114
[string]$ResourceGroupName,
1215

1316
[Parameter(Mandatory = $false, ValueFromPipeline = $true)]

src/Public/Get-AzWorkspaceManagerAssignmentJob.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ function Get-AzWorkspaceManagerAssignmentJob {
44
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
55
[ValidateNotNullOrEmpty()]
66
[ValidatePattern('^[A-Za-z0-9][A-Za-z0-9-]+[A-Za-z0-9]$', ErrorMessage="It does not match expected pattern '{1}'")]
7-
[string]$WorkspaceName,
7+
[Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters.ResourceNameCompleterAttribute(
8+
"Microsoft.OperationalInsights/workspaces",
9+
"ResourceGroupName"
10+
)][string]$WorkspaceName,
811

912
[Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
10-
[ValidateNotNullOrEmpty()]
13+
[Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters.ResourceGroupCompleterAttribute()]
1114
[string]$ResourceGroupName,
1215

1316
[Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $false)]

0 commit comments

Comments
 (0)