-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathFind-EntraBetaCommand.ps1
More file actions
127 lines (112 loc) · 4.87 KB
/
Copy pathFind-EntraBetaCommand.ps1
File metadata and controls
127 lines (112 loc) · 4.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
function Find-EntraBetaCommand {
[CmdletBinding(DefaultParameterSetName = 'GetQuery')]
param (
[Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[System.String] $Command,
[Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)]
[System.String] $Uri,
[Parameter(ParameterSetName = "GetQuery", Mandatory = $false, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[System.String] $ApiVersion="v1.0"
)
PROCESS {
$params = @{}
if($null -ne $PSBoundParameters["Command"])
{
$params["Command"]=$PSBoundParameters["Command"]
}
if($null -ne $PSBoundParameters["Uri"])
{
$params["Uri"] = $PSBoundParameters["Uri"]
}
if($null -ne $PSBoundParameters["ApiVersion"])
{
$params["ApiVersion"] = $PSBoundParameters["ApiVersion"]
}
if($PSBoundParameters.ContainsKey("Verbose"))
{
$params["Verbose"] = $Null
}
if($PSBoundParameters.ContainsKey("Debug"))
{
$params["Debug"] = $Null
}
if($null -ne $PSBoundParameters["WarningVariable"])
{
$params["WarningVariable"] = $PSBoundParameters["WarningVariable"]
}
if($null -ne $PSBoundParameters["InformationVariable"])
{
$params["InformationVariable"] = $PSBoundParameters["InformationVariable"]
}
if($null -ne $PSBoundParameters["InformationAction"])
{
$params["InformationAction"] = $PSBoundParameters["InformationAction"]
}
if($null -ne $PSBoundParameters["OutVariable"])
{
$params["OutVariable"] = $PSBoundParameters["OutVariable"]
}
if($null -ne $PSBoundParameters["OutBuffer"])
{
$params["OutBuffer"] = $PSBoundParameters["OutBuffer"]
}
if($null -ne $PSBoundParameters["ErrorVariable"])
{
$params["ErrorVariable"] = $PSBoundParameters["ErrorVariable"]
}
if($null -ne $PSBoundParameters["PipelineVariable"])
{
$params["PipelineVariable"] = $PSBoundParameters["PipelineVariable"]
}
if($null -ne $PSBoundParameters["ErrorAction"])
{
$params["ErrorAction"] = $PSBoundParameters["ErrorAction"]
}
if($null -ne $PSBoundParameters["WarningAction"])
{
$params["WarningAction"] = $PSBoundParameters["WarningAction"]
}
if($null -ne $PSBoundParameters["Top"])
{
$params["Top"] = $PSBoundParameters["Top"]
}
Write-Debug("============================ TRANSFORMATIONS ============================")
$params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug
Write-Debug("=========================================================================`n")
#Look up to map from a Cmdlet to the Uris.
$dictionary=@{}
###############################################################################################################################
#TODO: ADD NEW CMDLETS -> URIs MAPPINGS HERE
$dictionary["Set-EntraBetaApplicationProxyApplication"]=@("applications/{object-id}","applications/{object-Id}/connectorGroup")
$dictionary["New-EntraBetaApplicationProxyApplication"]=@("applications/{object-id}","/servicePrincipals","applications/{object-Id}/connectorGroup")
$dictionary["Remove-EntraBetaApplicationProxyApplicationConnectorGroup"]=@("applications/{object-Id}/connectorGroup")
##############################################################################################################################
$responses=@()
# keyCmdlet is the commandlet that maps to more than one API call.
$keyCmdlet=$params["Command"]
if ($null -ne $keyCmdlet) {
if($dictionary.ContainsKey($keyCmdlet)){
$uris = $dictionary.$keyCmdlet
foreach($uri in $uris){
$response=Find-MgGraphCommand -Uri $uri -ApiVersion beta
if($null -ne $response){
$responses+=$response
}
}
}
} else {
#Invoke the Find-MgGraphCommand with the params
$responses=Find-MgGraphCommand @params -ApiVersion beta
}
#Map the Command names and Module names
foreach($response in $responses){
$commandValue=$response.Command
$newCommandValue=$commandValue -replace '(Mg|MgGraph)', "Entra"
$response.Command=$newCommandValue
$appValue=$response.Module
$newAppValue=$appValue -replace "Beta", "EntraBeta"
$response.Module=$newAppValue
}
$responses
}
}