File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed
src/Resources/MSGraph.Autorest/custom Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ function Remove-AzAdAppCredential {
134
134
} else {
135
135
$list = @ ()
136
136
foreach ($key in $app.KeyCredentials ) {
137
- if (! $key .KeyId.Equals ( $ PSBoundParameters [' KeyId' ]) ) {
137
+ if ($ PSBoundParameters [' KeyId' ] -ne $key .KeyId ) {
138
138
$list += $key
139
139
}
140
140
}
@@ -143,16 +143,20 @@ function Remove-AzAdAppCredential {
143
143
$PSBoundParameters [' Id' ] = $app.Id
144
144
$PSBoundParameters [' KeyCredentials' ] = $list
145
145
MSGraph.internal\Update-AzAdApplication @PSBoundParameters
146
+ $foundKey = $true
146
147
} else {
147
148
foreach ($password in $app.PasswordCredentials ) {
148
- if ($password .KeyId.Equals ( $ PSBoundParameters [' KeyId' ]) ) {
149
+ if ($PSBoundParameters [' KeyId' ] -eq $password .KeyId ) {
149
150
$PSBoundParameters [' ApplicationId' ] = $app.Id
150
151
MSGraph.internal\Remove-AzAdApplicationPassword @PSBoundParameters
152
+ $foundKey = $true
151
153
break
152
154
}
153
155
}
154
156
}
155
- Write-Error " application '$ ( $app.Id ) ' does not contains credential with key id: '$ ( $PSBoundParameters [' KeyId' ]) '."
157
+ if (! $foundKey ) {
158
+ Write-Error " application '$ ( $app.Id ) ' does not contains credential with key id: '$ ( $PSBoundParameters [' KeyId' ]) '."
159
+ }
156
160
}
157
161
if ($PSBoundParameters [' PassThru' ]) {
158
162
$PSCmdlet.WriteObject ($true )
Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ function Remove-AzAdSpCredential {
134
134
} else {
135
135
$list = @ ()
136
136
foreach ($key in $sp.KeyCredentials ) {
137
- if (! $key .KeyId.Equals ( $ PSBoundParameters [' KeyId' ]) ) {
137
+ if ($ PSBoundParameters [' KeyId' ] -ne $key .KeyId ) {
138
138
$list += $key
139
139
}
140
140
}
@@ -143,16 +143,20 @@ function Remove-AzAdSpCredential {
143
143
$PSBoundParameters [' Id' ] = $sp.Id
144
144
$PSBoundParameters [' KeyCredentials' ] = $list
145
145
MSGraph.internal\Update-AzAdServicePrincipal @PSBoundParameters
146
+ $foundKey = $true
146
147
} else {
147
148
foreach ($password in $sp.PasswordCredentials ) {
148
- if ($password .KeyId.Equals ( $ PSBoundParameters [' KeyId' ]) ) {
149
+ if ($PSBoundParameters [' KeyId' ] -eq $password .KeyId ) {
149
150
$PSBoundParameters [' ServicePrincipalId' ] = $sp.Id
150
151
MSGraph.internal\Remove-AzAdServicePrincipalPassword @PSBoundParameters
152
+ $foundKey = $true
151
153
break
152
154
}
153
155
}
154
156
}
155
- Write-Error " service principal '$ ( $sp.Id ) ' does not contains credential with key id: '$ ( $PSBoundParameters [' KeyId' ]) '."
157
+ if (! $foundKey ) {
158
+ Write-Error " service principal '$ ( $sp.Id ) ' does not contains credential with key id: '$ ( $PSBoundParameters [' KeyId' ]) '."
159
+ }
156
160
if ($PSBoundParameters [' PassThru' ]) {
157
161
$PSCmdlet.WriteObject ($true )
158
162
}
You can’t perform that action at this time.
0 commit comments