|
149 | 149 |
|
150 | 150 | #region validity checks |
151 | 151 | if ($name -and @($url).count -gt 1) { |
152 | | - throw "'name' parameter cannot be used with multiple urls" |
| 152 | + Write-Warning "'name' parameter cannot be used with multiple urls" |
| 153 | + return |
153 | 154 | } |
154 | 155 |
|
155 | 156 | if ($placeholder -and $url -notlike "*<placeholder>*") { |
156 | | - throw "You have specified 'placeholder' parameter, but 'url' parameter doesn't contain string '<placeholder>' for replace." |
| 157 | + Write-Warning "You have specified 'placeholder' parameter, but 'url' parameter doesn't contain string '<placeholder>' for replace." |
| 158 | + return |
157 | 159 | } |
158 | 160 |
|
159 | 161 | if (!$placeholder -and $url -like "*<placeholder>*") { |
160 | | - throw "You have specified 'url' with '<placeholder>' in it, but not the 'placeholder' parameter itself." |
| 162 | + Write-Warning "You have specified 'url' with '<placeholder>' in it, but not the 'placeholder' parameter itself." |
| 163 | + return |
161 | 164 | } |
162 | 165 |
|
163 | 166 | if ($placeholderAsId -and !$placeholder) { |
164 | | - throw "'placeholderAsId' parameter cannot be used without specifying 'placeholder' parameter" |
| 167 | + Write-Warning "'placeholderAsId' parameter cannot be used without specifying 'placeholder' parameter" |
| 168 | + return |
165 | 169 | } |
166 | 170 |
|
167 | 171 | if ($placeholderAsId -and $placeholder -and @($url).count -gt 1) { |
168 | | - throw "'placeholderAsId' parameter cannot be used with multiple urls" |
| 172 | + Write-Warning "'placeholderAsId' parameter cannot be used with multiple urls" |
| 173 | + return |
169 | 174 | } |
170 | 175 |
|
171 | 176 | # api version check |
172 | 177 | $url | % { |
173 | 178 | if ($_ -notlike "*api-version=*") { |
174 | | - throw "URL '$_' is missing what api to use (api-version=2025-01-01 or similar). For example: 'https://management.azure.com/subscriptions/.../roleEligibilitySchedules?api-version=2020-10-01'. If you are unsure what api you can use, use the one from the example above and in case the request fails with 400 error, check the error message for the correct api version. Or use official Az cmdlet with -debug parameter and check the 'Absolute uri' output." |
| 179 | + Write-Warning "URL '$_' is missing what api to use (api-version=2025-01-01 or similar). For example: 'https://management.azure.com/subscriptions/.../roleEligibilitySchedules?api-version=2020-10-01'. If you are unsure what api you can use, use the one from the example above and in case the request fails with 400 error, check the error message for the correct api version. Or use official Az cmdlet with -debug parameter and check the 'Absolute uri' output." |
| 180 | + return |
175 | 181 | } |
176 | 182 | } |
177 | 183 | #endregion validity checks |
|
194 | 200 |
|
195 | 201 | #region url validity checks |
196 | 202 | if ($_ -notlike "https://management.azure.com/*" -and $_ -notlike "/*") { |
197 | | - throw "url '$_' has to be in the relative (without the 'https://management.azure.com' prefix and starting with the '/') or absolute form!" |
| 203 | + Write-Warning "url '$_' has to be in the relative (without the 'https://management.azure.com' prefix and starting with the '/') or absolute form!" |
| 204 | + return |
198 | 205 | } |
199 | 206 |
|
200 | 207 | if ($_ -notmatch "/subscriptions/|\?" -and $_ -notmatch "/providers/|\?" -and $_ -notmatch "/resources/|\?" -and $_ -notmatch "/locations/|\?" -and $_ -notmatch "/tenants/|\?" -and $_ -notmatch "/bulkdelete/|\?") { |
201 | | - throw "url '$_' is not valid. Is should starts with:`n/subscriptions, /providers, /resources, /locations, /tenants or /bulkdelete!" |
| 208 | + Write-Warning "url '$_' is not valid. Is should starts with:`n/subscriptions, /providers, /resources, /locations, /tenants or /bulkdelete!" |
| 209 | + return |
202 | 210 | } |
203 | 211 | #endregion url validity checks |
204 | 212 |
|
|
0 commit comments